Struct Predicate

Source
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>

Source§

impl<V: IriVocabulary> ExtractedFromVocabulary<V> for Predicate<V::Iri>

Source§

type Extracted = IriBuf

Source§

fn extracted_from_vocabulary(&self, vocabulary: &V) -> Self::Extracted

Exports a value embedded into the vocabulary V. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.