[−][src]Trait json_ld::ToReference
Types that can be converted into a borrowed node reference.
This is a convenient trait is used to simplify the use of references.
For instance consider the Node::get method, used to get the objects associated to the
given reference property for a given node.
It essentially have the following signature:
fn get(&self, id: &Reference<T>) -> Objects;
However building a Refrence by hand can be tedious, especilly while using Lexicon and
Vocab. It can be as verbose as node.get(&Reference::Id(Lexicon::Id(MyVocab::Term))).
Thanks to ToReference which is implemented by Lexicon<V> for any type V implementing Vocab,
it is simplified into node.get(MyVocab::Term) (while the first syntax remains correct) where
the signature of get becomes:
fn get<R: ToReference<T>>(&self, id: R) -> Objects;
Associated Types
type Reference: Borrow<Reference<T>>
The target type of the convertion, which can be borrowed as a Reference<T>.