[−][src]Enum json_ld::Lexicon
Lexicon identifier.
A Lexicon is a special identifier type (Id
) built from a Vocab
(vocabulary) type.
While Vocab
represents only a subset of all the possible IRIs, this type can also hold
any IRI outside of the predefined vocabulary.
It is a simple way to get an identifier type from a vocabulary.
Example
The following example builds a lexicon from a statically known vocabulary, defined as an
enum
type. It uses the iref-enum
crate to automatically derive the convertion of the
Vocab
type from/into IRIs.
#[macro_use] extern crate iref_enum; extern crate json_ld; use json_ld::Lexicon; /// Vocabulary used in the implementation. #[derive(IriEnum, Clone, Copy, PartialEq, Eq, Hash)] #[iri_prefix("rdfs" = "http://www.w3.org/2000/01/rdf-schema#")] #[iri_prefix("manifest" = "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#")] #[iri_prefix("vocab" = "https://w3c.github.io/json-ld-api/tests/vocab#")] pub enum Vocab { #[iri("rdfs:comment")] Comment, #[iri("manifest:name")] Name, #[iri("manifest:entries")] Entries, #[iri("manifest:action")] Action, #[iri("manifest:result")] Result, #[iri("vocab:PositiveEvaluationTest")] PositiveEvalTest, #[iri("vocab:NegativeEvaluationTest")] NegativeEvalTest, #[iri("vocab:option")] Option, #[iri("vocab:specVersion")] SpecVersion, #[iri("vocab:processingMode")] ProcessingMode, #[iri("vocab:expandContext")] ExpandContext, #[iri("vocab:base")] Base } /// A fully functional identifier type. pub type Id = Lexicon<Vocab>; fn handle_node(node: &json_ld::Node<Id>) { for name in node.get(Vocab::Name) { // <- note that we can directly use `Vocab` here. println!("node name: {}", name.as_str().unwrap()); } }
Variants
Identifier from the known vocabulary.
Iri(IriBuf)
Any other IRI outside of the vocabulary.
Trait Implementations
impl<V: Clone + Vocab> Clone for Lexicon<V>
[src]
impl<V: Vocab> Display for Lexicon<V>
[src]
impl<V: Eq + Vocab> Eq for Lexicon<V>
[src]
impl<V: Hash + Vocab> Hash for Lexicon<V>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<V: Vocab> Id for Lexicon<V>
[src]
impl<V: PartialEq + Vocab> PartialEq<Lexicon<V>> for Lexicon<V>
[src]
impl<V: Vocab> PartialEq<V> for Lexicon<V>
[src]
impl<V: Vocab> StructuralEq for Lexicon<V>
[src]
impl<V: Vocab> StructuralPartialEq for Lexicon<V>
[src]
impl<V: Vocab> ToReference<Lexicon<V>> for V
[src]
Auto Trait Implementations
impl<V> RefUnwindSafe for Lexicon<V> where
V: RefUnwindSafe,
V: RefUnwindSafe,
impl<V> Send for Lexicon<V> where
V: Send,
V: Send,
impl<V> Sync for Lexicon<V> where
V: Sync,
V: Sync,
impl<V> Unpin for Lexicon<V> where
V: Unpin,
V: Unpin,
impl<V> UnwindSafe for Lexicon<V> where
V: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToOwned for T
[src]
type Owned = T
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,