pub enum Context {
One(ContextEntry),
Many(Vec<ContextEntry>),
}Expand description
JSON-LD Context.
Can represent a single context entry, or a list of context entries.
Variants§
One(ContextEntry)
A single entry, written on its own.
Many(Vec<ContextEntry>)
Several entries, written as a JSON array.
Implementations§
Source§impl Context
impl Context
Sourcepub fn one(context: ContextEntry) -> Self
pub fn one(context: ContextEntry) -> Self
Creates a new context with a single entry.
Sourcepub fn iri_ref(iri_ref: IriRefBuf) -> Self
pub fn iri_ref(iri_ref: IriRefBuf) -> Self
Creates a new context with a single IRI-reference entry.
Sourcepub fn definition(def: Definition) -> Self
pub fn definition(def: Definition) -> Self
Creates a new context with a single context definition entry.
Source§impl Context
impl Context
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of entries of this context, which is 1 for a single entry.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks whether this context has no entry, which only an empty array can.
Sourcepub fn as_slice(&self) -> &[ContextEntry]
pub fn as_slice(&self) -> &[ContextEntry]
Returns the entries of this context as a slice.
Sourcepub fn is_object(&self) -> bool
pub fn is_object(&self) -> bool
Checks whether this context is a single context definition, written as a JSON object.
Sourcepub fn traverse(&self) -> Traverse<'_> ⓘ
pub fn traverse(&self) -> Traverse<'_> ⓘ
Returns a depth-first iterator over this context and every fragment it contains, itself included.
Sourcepub fn iter(&self) -> Iter<'_, ContextEntry> ⓘ
pub fn iter(&self) -> Iter<'_, ContextEntry> ⓘ
Returns an iterator over the entries of this context, in order.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Context
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Context
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Context
Source§impl From<ContextEntry> for Context
impl From<ContextEntry> for Context
Source§fn from(c: ContextEntry) -> Self
fn from(c: ContextEntry) -> Self
Source§impl From<Definition> for Context
impl From<Definition> for Context
Source§fn from(c: Definition) -> Self
fn from(c: Definition) -> Self
Source§impl IntoIterator for Context
impl IntoIterator for Context
Source§impl<'a> IntoIterator for &'a Context
impl<'a> IntoIterator for &'a Context
Source§impl PrecomputeSize for Context
impl PrecomputeSize for Context
Source§impl Print for Context
impl Print for Context
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
options: &Options,
indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl PrintWithSize for Context
impl PrintWithSize for Context
impl StructuralPartialEq for Context
Source§impl TryFromJson for Context
impl TryFromJson for Context
Source§type Error = InvalidContext
type Error = InvalidContext
Self.Source§fn try_from_json(value: &Value) -> Result<Self, InvalidContext>
fn try_from_json(value: &Value) -> Result<Self, InvalidContext>
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
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
Source§fn as_unordered(&self) -> &Unordered<T>
fn as_unordered(&self) -> &Unordered<T>
Unordered reference.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self is equivalent to key.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
key and return true if they are equal.