[−][src]Enum sophia_term::Term
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]
T: TermData,
pub fn write_fmt<W>(&self, w: &mut W) -> Result where
W: Write,
[src]
W: Write,
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]
W: Write,
Writes the term to the io::Write
using the N3 syntax.
impl<T> Term<T> where
T: TermData,
[src]
T: TermData,
pub fn new_iri<U>(iri: U) -> Result<Term<T>> where
U: AsRef<str>,
T: From<U>,
[src]
U: AsRef<str>,
T: From<U>,
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]
U: AsRef<str>,
V: AsRef<str>,
T: From<U> + From<V>,
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]
U: AsRef<str>,
T: From<U>,
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]
V: AsRef<str>,
T: From<U> + From<V>,
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]
T: From<U>,
V: TryInto<Iri<T>>,
TermError: From<<V as TryInto<Iri<T>>>::Error>,
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]
U: AsRef<str>,
T: From<U>,
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]
F: FnMut(T) -> TD2,
TD2: TermData,
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]
T: Into<TD2>,
TD2: TermData,
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]
U: TermData,
F: FnMut(&'a str) -> U,
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]
U: TermData + From<&'src str>,
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]
T: From<U>,
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]
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.
pub fn new_bnode_unchecked<U>(id: U) -> Term<T> where
U: AsRef<str>,
T: From<U>,
[src]
U: AsRef<str>,
T: From<U>,
pub fn new_literal_lang_unchecked<U, V>(txt: U, lang: V) -> Self where
V: AsRef<str>,
T: From<U> + From<V>,
[src]
V: AsRef<str>,
T: From<U> + From<V>,
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]
T: From<U>,
V: TryInto<Iri<T>>,
<V as TryInto<Iri<T>>>::Error: Debug,
pub fn new_variable_unchecked<U>(name: U) -> Term<T> where
U: AsRef<str>,
T: From<U>,
[src]
U: AsRef<str>,
T: From<U>,
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]
TD: TermData,
impl<TD: Copy> Copy for Term<TD> where
TD: TermData,
[src]
TD: TermData,
impl<TD> CopyTerm for Term<TD> where
TD: TermData + for<'x> From<&'x str>,
[src]
TD: TermData + for<'x> From<&'x str>,
impl<TD: Debug> Debug for Term<TD> where
TD: TermData,
[src]
TD: TermData,
impl<T> Display for Term<T> where
T: TermData,
[src]
T: TermData,
impl<TD: Eq> Eq for Term<TD> where
TD: TermData,
[src]
TD: TermData,
impl<TD> From<BlankNode<TD>> for Term<TD> where
TD: TermData,
[src]
TD: TermData,
impl<TD> From<Iri<TD>> for Term<TD> where
TD: TermData,
[src]
TD: TermData,
impl<TD> From<Literal<TD>> for Term<TD> where
TD: TermData,
[src]
TD: TermData,
impl<T: ?Sized, TD> From<NativeLiteral<T, Box<str>>> for Term<TD> where
T: DataType,
TD: TermData + From<Box<str>> + From<&'static str>,
[src]
T: DataType,
TD: TermData + From<Box<str>> + From<&'static str>,
fn from(other: NativeLiteral<T>) -> Self
[src]
impl<TD> From<String> for Term<TD> where
TD: TermData + From<Box<str>> + From<&'static str>,
[src]
TD: TermData + From<Box<str>> + From<&'static str>,
impl<TD> From<Variable<TD>> for Term<TD> where
TD: TermData,
[src]
TD: TermData,
impl<TD> Hash for Term<TD> where
TD: TermData,
[src]
TD: TermData,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<TD: Ord> Ord for Term<TD> where
TD: TermData,
[src]
TD: TermData,
fn cmp(&self, other: &Term<TD>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<TD, TE: ?Sized> PartialEq<TE> for Term<TD> where
TD: TermData,
TE: TTerm,
[src]
TD: TermData,
TE: TTerm,
impl<TD, TE: ?Sized> PartialOrd<TE> for Term<TD> where
TD: TermData,
TE: TTerm,
[src]
TD: TermData,
TE: TTerm,
fn partial_cmp(&self, other: &TE) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b, TD> Resolve<&'a Term<TD>, Term<MownStr<'a>>> for IriParsed<'b> where
TD: TermData,
[src]
TD: TermData,
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]
TD: TermData,
impl<T: TermData> TTerm for Term<T>
[src]
fn kind(&self) -> TermKind
[src]
fn value_raw(&self) -> RawValue<'_>
[src]
fn datatype(&self) -> Option<SimpleIri<'_>>
[src]
fn language(&self) -> Option<&str>
[src]
fn as_dyn(&self) -> &dyn TTerm
[src]
fn value(&self) -> MownStr<'_>
[src]
fn is_absolute(&self) -> bool
[src]
impl<'a, T, U> TryFrom<&'a Term<U>> for Variable<T> where
T: TermData + From<&'a str>,
U: TermData,
[src]
T: TermData + From<&'a str>,
U: TermData,
type Error = TermError
The type returned in the event of a conversion error.
fn try_from(term: &'a Term<U>) -> Result<Self, Self::Error>
[src]
impl<'a, T, U> TryFrom<&'a Term<U>> for BlankNode<T> where
T: TermData + From<&'a str>,
U: TermData,
[src]
T: TermData + From<&'a str>,
U: TermData,
type Error = TermError
The type returned in the event of a conversion error.
fn try_from(term: &'a Term<U>) -> Result<Self, Self::Error>
[src]
impl<'a, T, U> TryFrom<&'a Term<U>> for Iri<T> where
T: TermData + From<&'a str>,
U: TermData,
[src]
T: TermData + From<&'a str>,
U: TermData,
type Error = TermError
The type returned in the event of a conversion error.
fn try_from(term: &'a Term<U>) -> Result<Self, Self::Error>
[src]
impl<'a, T, U> TryFrom<&'a Term<U>> for Literal<T> where
T: TermData + From<&'a str>,
U: TermData,
[src]
T: TermData + From<&'a str>,
U: TermData,
type Error = TermError
The type returned in the event of a conversion error.
fn try_from(term: &'a Term<U>) -> Result<Self, Self::Error>
[src]
impl<TD> TryFrom<Term<TD>> for Variable<TD> where
TD: TermData,
[src]
TD: TermData,
type Error = TermError
The type returned in the event of a conversion error.
fn try_from(term: Term<TD>) -> Result<Self, Self::Error>
[src]
impl<TD> TryFrom<Term<TD>> for BlankNode<TD> where
TD: TermData,
[src]
TD: TermData,
type Error = TermError
The type returned in the event of a conversion error.
fn try_from(term: Term<TD>) -> Result<Self, Self::Error>
[src]
impl<TD> TryFrom<Term<TD>> for Iri<TD> where
TD: TermData,
[src]
TD: TermData,
type Error = TermError
The type returned in the event of a conversion error.
fn try_from(term: Term<TD>) -> Result<Self, Self::Error>
[src]
impl<TD> TryFrom<Term<TD>> for Literal<TD> where
TD: TermData,
[src]
TD: TermData,
Auto Trait Implementations
impl<TD> RefUnwindSafe for Term<TD> where
TD: RefUnwindSafe,
TD: RefUnwindSafe,
impl<TD> Send for Term<TD> where
TD: Send,
TD: Send,
impl<TD> Sync for Term<TD> where
TD: Sync,
TD: Sync,
impl<TD> Unpin for Term<TD> where
TD: Unpin,
TD: Unpin,
impl<TD> UnwindSafe for Term<TD> where
TD: UnwindSafe,
TD: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> ConvertibleTerm for T where
T: TTerm + ?Sized,
[src]
T: TTerm + ?Sized,
fn try_converted<U>(&Self) -> Result<U, TermError> where
U: TryConvertTerm,
<U as FromStr>::Err: Error,
<U as FromStr>::Err: 'static,
[src]
U: TryConvertTerm,
<U as FromStr>::Err: Error,
<U as FromStr>::Err: 'static,
impl<T> CopiableTerm for T where
T: TTerm + ?Sized,
[src]
T: TTerm + ?Sized,
fn copied<U>(&self) -> U where
U: CopyTerm,
[src]
U: CopyTerm,
fn try_copied<U>(&self) -> Result<U, <U as TryCopyTerm>::Error> where
U: TryCopyTerm,
[src]
U: TryCopyTerm,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<U> TermMatcher for U where
U: TTerm + ?Sized,
[src]
U: TTerm + ?Sized,
type Term = U
Type of TTerm
used internally by this matcher.
fn constant(&self) -> Option<&U>
[src]
fn matches<T>(&self, t: &T) -> bool where
T: TTerm + ?Sized,
[src]
T: TTerm + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,