pub struct Context(/* private fields */);Expand description
The @context of a DID document, carried verbatim: a string, a map or a non-empty array of
them.
This crate does no JSON-LD processing; the context is data that round-trips.
§Examples
use identity_kit::did::Context;
let context = Context::uris([Context::DID_V1, "https://w3id.org/security/suites/jws-2020/v1"]);
assert!(context.contains(Context::DID_V1));
assert_eq!(
serde_json::to_string(&context)?,
r#"["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/jws-2020/v1"]"#
);Implementations§
Source§impl Context
impl Context
Sourcepub fn new(value: Value) -> Result<Self, DocumentError>
pub fn new(value: Value) -> Result<Self, DocumentError>
Any JSON value allowed as a context.
§Errors
DocumentError::InvalidContext unless value is a string, a map or a non-empty array.
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
The context as JSON.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Context
impl<'de> Deserialize<'de> for Context
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Context
impl StructuralPartialEq for Context
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl UnwindSafe for Context
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.