[][src]Enum sophia_term::Term

pub enum Term<TD> where
    TD: TermData
{ Iri(Iri<TD>), BNode(BlankNode<TD>), Literal(Literal<TD>), Variable(Variable<TD>), }

Generic type for RDF terms.

See module documentation for more detail.

Variants

Iri(Iri<TD>)

An IRI referencing a resource.

BNode(BlankNode<TD>)

A blank node.

Also known as existentially quantified variable.

Literal(Literal<TD>)

An RDF literal.

Variable(Variable<TD>)

A universally quantified variable like in SPARQL or Notation3.

Implementations

impl<T> Term<T> where
    T: TermData
[src]

pub fn write_fmt<W>(&self, w: &mut W) -> Result where
    W: Write
[src]

Writes the term to the fmt::Write using the NTriples syntax.

This means the IRI is in angled brackets and no prefix is used.

pub fn write_io<W>(&self, w: &mut W) -> Result<()> where
    W: Write
[src]

Writes the term to the io::Write using the N3 syntax.

impl<T> Term<T> where
    T: TermData
[src]

pub fn new_iri<U>(iri: U) -> Result<Term<T>> where
    U: AsRef<str>,
    T: From<U>, 
[src]

Return a new IRI term from the given text.

May fail if txt is not a valid IRI.

pub fn new_iri_suffixed<U, V>(ns: U, suffix: V) -> Result<Term<T>> where
    U: AsRef<str>,
    V: AsRef<str>,
    T: From<U> + From<V>, 
[src]

Return a new IRI term from the two given parts (prefix and suffix).

May fail if the concatenation of ns and suffix does not produce a valid IRI.

pub fn new_bnode<U>(id: U) -> Result<Term<T>> where
    U: AsRef<str>,
    T: From<U>, 
[src]

Return a new blank node term with the given bnode ID.

Currently, this may never fail; however it returns a result for homogeneity with other constructor methods, and because future versions may be more picky regarding bnode IDs.

pub fn new_literal_lang<U, V>(txt: U, lang: V) -> Result<Self> where
    V: AsRef<str>,
    T: From<U> + From<V>, 
[src]

Return a new literal term with the given value and language tag.

May fail if the language tag is not a valid BCP47 language tag.

pub fn new_literal_dt<U, V>(txt: U, dt: V) -> Result<Self> where
    T: From<U>,
    V: TryInto<Iri<T>>,
    TermError: From<<V as TryInto<Iri<T>>>::Error>, 
[src]

Return a new literal term with the given value and datatype.

May fail if dt is not an IRI.

pub fn new_variable<U>(name: U) -> Result<Term<T>> where
    U: AsRef<str>,
    T: From<U>, 
[src]

Return a new variable term with the given name.

May fail if name is not a valid variable name.

pub fn as_ref(&self) -> Term<&T>[src]

Borrow the inner contents of the term.

pub fn as_ref_str(&self) -> Term<&str>[src]

Borrow the inner contents of the term as &str.

pub fn map<F, TD2>(self, f: F) -> Term<TD2> where
    F: FnMut(T) -> TD2,
    TD2: TermData
[src]

Create a new term by applying f to the TermData of self.

pub fn map_into<TD2>(self) -> Term<TD2> where
    T: Into<TD2>,
    TD2: TermData
[src]

Maps the term using the Into trait.

pub fn clone_map<'a, U, F>(&'a self, factory: F) -> Term<U> where
    U: TermData,
    F: FnMut(&'a str) -> U, 
[src]

Clone self while transforming the inner TermData with the given factory.

This is done in one step in contrast to calling clone().map(factory).

pub fn clone_into<'src, U>(&'src self) -> Term<U> where
    U: TermData + From<&'src str>, 
[src]

Apply clone_map() using the Into trait.

pub fn normalized(&self, policy: Normalization) -> MownTerm<'_>[src]

Return a term equivalent to this one, with all IRIs (if any) internally represented with all its data in ns, and an empty suffix.

Performances

The returned term will borrow data from this one as much as possible, but strings may be allocated in case a concatenation is required.

pub fn new_iri_unchecked<U>(iri: U) -> Term<T> where
    T: From<U>, 
[src]

Create a new IRI-term from a given IRI without checking its validity.

Pre-conditions

This function conducts no checks if the resulting IRI is valid. This is a contract that is generally assumed. Breaking it could result in unexpected behavior.

However, in debug builds assertions that perform checks are enabled.

pub fn new_iri_suffixed_unchecked<U, V>(ns: U, suffix: V) -> Term<T> where
    T: From<U> + From<V>, 
[src]

Create a new IRI-term from a given namespace and suffix.

Pre-conditions

It is expected that

  • the resulting IRI is valid per RFC3987,
  • suffix is not the empty string (otherwise, new_iri_unchecked should be used instead).

This is a contract that is generally assumed. Breaking it could result in unexpected behavior. However in debug mode, assertions that perform checks are enabled.

pub fn new_bnode_unchecked<U>(id: U) -> Term<T> where
    U: AsRef<str>,
    T: From<U>, 
[src]

Return a new blank node term.

Pre-condition

This function requires that id is a valid bnode ID.

pub fn new_literal_lang_unchecked<U, V>(txt: U, lang: V) -> Self where
    V: AsRef<str>,
    T: From<U> + From<V>, 
[src]

Return a literal term.

Pre-condition

This function requires that lang is a valid language tag. In debug mode this constraint is asserted.

pub fn new_literal_dt_unchecked<U, V>(txt: U, dt: V) -> Self where
    T: From<U>,
    V: TryInto<Iri<T>>,
    <V as TryInto<Iri<T>>>::Error: Debug
[src]

Return a typed literal term.

Panics

Panics if dt cannot be converted into an IRI.

pub fn new_variable_unchecked<U>(name: U) -> Term<T> where
    U: AsRef<str>,
    T: From<U>, 
[src]

Return a new variable term.

Pre-condition

This function requires that name is a valid variable name.

Trait Implementations

impl<TD: Clone> Clone for Term<TD> where
    TD: TermData
[src]

impl<TD: Copy> Copy for Term<TD> where
    TD: TermData
[src]

impl<TD> CopyTerm for Term<TD> where
    TD: TermData + for<'x> From<&'x str>, 
[src]

impl<TD: Debug> Debug for Term<TD> where
    TD: TermData
[src]

impl<T> Display for Term<T> where
    T: TermData
[src]

impl<TD: Eq> Eq for Term<TD> where
    TD: TermData
[src]

impl<TD> From<BlankNode<TD>> for Term<TD> where
    TD: TermData
[src]

impl<TD> From<Iri<TD>> for Term<TD> where
    TD: TermData
[src]

impl<TD> From<Literal<TD>> for Term<TD> where
    TD: TermData
[src]

impl<T: ?Sized, TD> From<NativeLiteral<T, Box<str>>> for Term<TD> where
    T: DataType,
    TD: TermData + From<Box<str>> + From<&'static str>, 
[src]

impl<TD> From<String> for Term<TD> where
    TD: TermData + From<Box<str>> + From<&'static str>, 
[src]

impl<TD> From<Variable<TD>> for Term<TD> where
    TD: TermData
[src]

impl<TD> Hash for Term<TD> where
    TD: TermData
[src]

impl<TD: Ord> Ord for Term<TD> where
    TD: TermData
[src]

impl<TD, TE: ?Sized> PartialEq<TE> for Term<TD> where
    TD: TermData,
    TE: TTerm
[src]

impl<TD, TE: ?Sized> PartialOrd<TE> for Term<TD> where
    TD: TermData,
    TE: TTerm
[src]

impl<'a, 'b, TD> Resolve<&'a Term<TD>, Term<MownStr<'a>>> for IriParsed<'b> where
    TD: TermData
[src]

fn resolve(&self, other: &'a Term<TD>) -> MownTerm<'a>[src]

Resolve IRIs and the IRIs of typed literals.

Performance

May allocate an intermediate IRI if an IRI is suffixed.

impl<TD> StructuralEq for Term<TD> where
    TD: TermData
[src]

impl<T: TermData> TTerm for Term<T>[src]

impl<'a, T, U> TryFrom<&'a Term<U>> for Variable<T> where
    T: TermData + From<&'a str>,
    U: TermData
[src]

type Error = TermError

The type returned in the event of a conversion error.

impl<'a, T, U> TryFrom<&'a Term<U>> for BlankNode<T> where
    T: TermData + From<&'a str>,
    U: TermData
[src]

type Error = TermError

The type returned in the event of a conversion error.

impl<'a, T, U> TryFrom<&'a Term<U>> for Iri<T> where
    T: TermData + From<&'a str>,
    U: TermData
[src]

type Error = TermError

The type returned in the event of a conversion error.

impl<'a, T, U> TryFrom<&'a Term<U>> for Literal<T> where
    T: TermData + From<&'a str>,
    U: TermData
[src]

type Error = TermError

The type returned in the event of a conversion error.

impl<TD> TryFrom<Term<TD>> for Variable<TD> where
    TD: TermData
[src]

type Error = TermError

The type returned in the event of a conversion error.

impl<TD> TryFrom<Term<TD>> for BlankNode<TD> where
    TD: TermData
[src]

type Error = TermError

The type returned in the event of a conversion error.

impl<TD> TryFrom<Term<TD>> for Iri<TD> where
    TD: TermData
[src]

type Error = TermError

The type returned in the event of a conversion error.

impl<TD> TryFrom<Term<TD>> for Literal<TD> where
    TD: TermData
[src]

type Error = TermError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<TD> RefUnwindSafe for Term<TD> where
    TD: RefUnwindSafe

impl<TD> Send for Term<TD> where
    TD: Send

impl<TD> Sync for Term<TD> where
    TD: Sync

impl<TD> Unpin for Term<TD> where
    TD: Unpin

impl<TD> UnwindSafe for Term<TD> where
    TD: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ConvertibleTerm for T where
    T: TTerm + ?Sized
[src]

impl<T> CopiableTerm for T where
    T: TTerm + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<U> TermMatcher for U where
    U: TTerm + ?Sized
[src]

type Term = U

Type of TTerm used internally by this matcher.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.