pub struct Predicate<T>(pub T);
Expand description
Wrapper type to allow an arbitrary type to be recognized as an RDF IRI predicate.
§Example
use rdf_types::{Id, Term, Quad, LexicalQuad, vocabulary::{IndexVocabulary, IriVocabularyMut, IriIndex, BlankIdIndex, LiteralIndex, ExtractFromVocabulary, Predicate, ByRef}};
use static_iref::iri;
let mut vocabulary = IndexVocabulary::new();
type IdRef<'a> = Id<&'a IriIndex, &'a BlankIdIndex>;
type TermRef<'a> = Term<IdRef<'a>, &'a LiteralIndex>;
type QuadRef<'a> = Quad<IdRef<'a>, &'a IriIndex, TermRef<'a>, IdRef<'a>>;
let subject = vocabulary.insert(iri!("http://example.org/#subject"));
let predicate = vocabulary.insert(iri!("http://example.org/#property"));
let object = vocabulary.insert(iri!("http://example.org/#object"));
let quad: QuadRef = Quad(
Id::Iri(&subject),
&predicate,
Term::iri(&object),
None
);
let _: LexicalQuad = ByRef(
quad.map_predicate(Predicate) // ensures the `&IriIndex` type is interpreted as a predicate.
).extract_from_vocabulary(&vocabulary);
Tuple Fields§
§0: T
Trait Implementations§
Source§impl<V: IriVocabulary> ExtractFromVocabulary<V> for Predicate<V::Iri>
impl<V: IriVocabulary> ExtractFromVocabulary<V> for Predicate<V::Iri>
Auto Trait Implementations§
impl<T> Freeze for Predicate<T>where
T: Freeze,
impl<T> RefUnwindSafe for Predicate<T>where
T: RefUnwindSafe,
impl<T> Send for Predicate<T>where
T: Send,
impl<T> Sync for Predicate<T>where
T: Sync,
impl<T> Unpin for Predicate<T>where
T: Unpin,
impl<T> UnwindSafe for Predicate<T>where
T: UnwindSafe,
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