Enum sophia_term::Term
source · [−]pub enum Term<TD> where
TD: TermData, {
Iri(Iri<TD>),
BNode(BlankNode<TD>),
Literal(Literal<TD>),
Variable(Variable<TD>),
}
Expand description
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
Writes the term to the fmt::Write
using the NTriples syntax.
This means the IRI is in angled brackets and no prefix is used.
Return a new IRI term from the given text.
May fail if txt
is not a valid IRI.
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.
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.
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.
Return a new literal term with the given value and datatype.
May fail if dt
is not an IRI.
Return a new variable term with the given name.
May fail if name
is not a valid variable name.
Borrow the inner contents of the term as &str
.
Create a new term by applying f
to the TermData
of self
.
Maps the term using the Into
trait.
Clone self while transforming the inner TermData
with the given
factory.
This is done in one step in contrast to calling clone().map(factory)
.
Apply clone_map()
using the Into
trait.
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.
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>,
pub fn new_iri_suffixed_unchecked<U, V>(ns: U, suffix: V) -> Term<T> where
T: From<U> + From<V>,
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.
Return a literal term.
Pre-condition
This function requires that lang
is a valid language tag.
In debug mode this constraint is asserted.
Return a new variable term.
Pre-condition
This function requires that name
is a valid variable name.
Trait Implementations
Performs the conversion.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Resolve IRIs and the IRIs of typed literals.
Performance
May allocate an intermediate IRI if an IRI is suffixed.
Return the “value” of this term, possibly split in two substrings. The second part might only be non-empty if this term is an IRI reference. Read more
Return the datatype IRI of this term if it is a literal. Read more
Return the language tag of this term if it is a language-tagged literal. Read more
This method ensures that all implementations of TTerm
can be turned into a trait object. Read more
Return the “value” of this term, which depends on its kind: Read more
All terms are absolute, except for: Read more
Auto Trait Implementations
impl<TD> RefUnwindSafe for Term<TD> where
TD: RefUnwindSafe,
impl<TD> UnwindSafe for Term<TD> where
TD: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
fn try_converted<U>(&self) -> Result<U> where
U: TryConvertTerm,
<U as FromStr>::Err: Error + 'static,
fn try_converted<U>(&self) -> Result<U> where
U: TryConvertTerm,
<U as FromStr>::Err: Error + 'static,
Try to convert this term into a native type
Try to copy this IRI into another type.