pub struct InMemoryDocuments {
bodies: HashMap<String, String>,
}Expand description
A DidDocumentSource backed by a map from URL to response body.
The test double, and also a usable cache or fixture loader. Keys are the
full URLs AccountDid::did_json_url produces, so a test that gets the
scheme or the port wrong sees a ResolveError::NotFound rather than
silently passing.
Fields§
§bodies: HashMap<String, String>Implementations§
Source§impl InMemoryDocuments
impl InMemoryDocuments
Sourcepub fn insert_body(&mut self, url: &str, body: &str) -> &mut Self
pub fn insert_body(&mut self, url: &str, body: &str) -> &mut Self
Stores a raw body at url. Use this to test malformed responses.
Sourcepub fn insert(
&mut self,
did: &AccountDid,
document: &DidDocument,
) -> Result<&mut Self, Error>
pub fn insert( &mut self, did: &AccountDid, document: &DidDocument, ) -> Result<&mut Self, Error>
Serializes document and serves it at did’s document URL.
Returns the serialization error rather than panicking, so callers keep
their no-unwrap discipline.
Trait Implementations§
Source§impl Clone for InMemoryDocuments
impl Clone for InMemoryDocuments
Source§fn clone(&self) -> InMemoryDocuments
fn clone(&self) -> InMemoryDocuments
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InMemoryDocuments
impl Debug for InMemoryDocuments
Source§impl Default for InMemoryDocuments
impl Default for InMemoryDocuments
Source§fn default() -> InMemoryDocuments
fn default() -> InMemoryDocuments
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InMemoryDocuments
impl RefUnwindSafe for InMemoryDocuments
impl Send for InMemoryDocuments
impl Sync for InMemoryDocuments
impl Unpin for InMemoryDocuments
impl UnsafeUnpin for InMemoryDocuments
impl UnwindSafe for InMemoryDocuments
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more