[−][src]Struct sophia_term::iri::Iri
An IRI reference.
Contract
Each Iri
represents a valid IRI reference according to the
RFC3987 either relative or absolute.
This is checked by standard constructors (new
and new_suffixed
).
On the other hand,
it is the obligation of the user to ensure that invocations of *_unchecked()
methods produce valid output. Note that the creation of invalid IRIs may
lead to unexpected errors in other places.
Implementations
impl<TD> Iri<TD> where
TD: TermData,
[src]
TD: TermData,
pub fn new<U>(iri: U) -> Result<Self> where
U: AsRef<str>,
TD: From<U>,
[src]
U: AsRef<str>,
TD: From<U>,
Return a new IRI-term from a given IRI.
It is checked if the input is either an absolute or relative IRI. If it is none of them an error is returned.
pub fn new_suffixed<U, V>(ns: U, suffix: V) -> Result<Self> where
U: AsRef<str>,
V: AsRef<str>,
TD: From<U> + From<V>,
[src]
U: AsRef<str>,
V: AsRef<str>,
TD: From<U> + From<V>,
Return a new IRI-term from a given namespace and suffix.
It is checked if the input is either an absolute or relative IRI. If it is none of them an error is returned.
Performance
In order to check if the concatenation of namespace and suffix results in a valid IRI a new String is allocated and namespace and suffix are copied into it.
pub fn new_unchecked<U>(iri: U) -> Self where
TD: From<U>,
[src]
TD: From<U>,
Create a new IRI-term from a given IRI without checking its validity.
Pre-condition
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_suffixed_unchecked<U, V>(ns: U, suffix: V) -> Self where
TD: From<U> + From<V>,
[src]
TD: 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_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 ns(&self) -> &TD
[src]
The namespace of the IRI.
If the IRI has no suffix this is the whole IRI.
pub fn suffix(&self) -> &Option<TD>
[src]
The suffix of the IRI.
pub fn as_ref(&self) -> Iri<&TD>
[src]
Borrow the inner contents of the IRI.
pub fn as_ref_str(&self) -> Iri<&str>
[src]
Borrow the inner contents of the IRI as &str
.
pub fn map<F, TD2>(self, f: F) -> Iri<TD2> where
F: FnMut(TD) -> TD2,
TD2: TermData,
[src]
F: FnMut(TD) -> TD2,
TD2: TermData,
Create a new IRI by applying f
to the TermData
of self
.
pub fn map_into<TD2>(self) -> Iri<TD2> where
TD: Into<TD2>,
TD2: TermData,
[src]
TD: Into<TD2>,
TD2: TermData,
Maps the IRI using the Into
trait.
pub fn clone_map<'a, U, F>(&'a self, factory: F) -> Iri<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) -> Iri<U> where
U: TermData + From<&'src str>,
[src]
U: TermData + From<&'src str>,
Apply clone_map()
using the Into
trait.
pub fn len(&self) -> usize
[src]
The length of this IRI.
pub fn is_empty(&self) -> bool
[src]
An empty IRI is not a valid one
Checks if the IRI is empty
pub fn bytes(&self) -> impl '_ + Iterator<Item = u8>
[src]
Iterate over the bytes representing this IRI.
pub fn chars(&self) -> impl '_ + Iterator<Item = char>
[src]
Iterate over the characters representing this IRI.
pub fn has_suffix(&self) -> bool
[src]
Whether this IRI is is composed of a whole IRI (false
) or a namespace
and a suffix (true
).
pub fn normalized(&self, policy: Normalization) -> Iri<MownStr<'_>>
[src]
Return an IRI equivalent to this one,
internally represented with all its data in ns
, and an empty suffix
.
Performances
The returned IRI will borrow data from this one as much as possible, but strings may be allocated in case a concatenation is required.
pub fn normalized_no_suffix(&self) -> Iri<MownStr<'_>>
[src]
Return an IRI equivalent to this one,
internally represented with all its data in ns
, and an empty suffix
.
Performances
If this IRI has an empty suffix, the returned IRI simply borrows its ns
.
Otherwise, a new string is allocated for the returned IRI.
pub fn normalized_suffixed_at_last_gen_delim(&self) -> Iri<MownStr<'_>>
[src]
Return an IRI equivalent to this one,
internally represented with ns
extending to the last gen-delims characters
(i.e. ":" / "/" / "?" / "#" / "[" / "]" / "@"). and
suffix` containing the rest.
Performances
The returned IRI will borrow data from this one as much as possible, but strings may be allocated in case a concatenation is required.
pub fn match_ns<'s, U>(
&'s self,
ns: &Iri<U>
) -> Option<impl 's + Iterator<Item = char>> where
U: TermData,
[src]
&'s self,
ns: &Iri<U>
) -> Option<impl 's + Iterator<Item = char>> where
U: TermData,
Checks if the IRI matches a namespace.
If it does the remaining suffix is returned as iterator of char
s.
This prevents an additional allocation.
In case the ns
and the IRI are the same, the function succeeds but
returns an empty Iterator
.
pub fn parse_components<'s>(&'s self, buffer: &'s mut String) -> IriParsed<'s>
[src]
Parses the components of the IRI.
This is necessary to use the IRI as a base to resolve other IRIs.
Auxiliary buffer
The buffer parameter is only required in the situation where
the internal representation of this Iri
makes it unsuitable
for building an IriParsed
(typically because it is split in an ns
and a suffix
part).
In those situations, the buffer will be used to store the full IRI,
and will be borrowed by the returned IriParsed
.
Otherwise, the buffer will not be used,
the data will be borrowed directly from self
.
Implementation detail
Currently, the buffer is used whenever the IRI is internally stored in two parts
(ns and suffix), i.e. when it was created with new_suffixed
.
Technically a suffixed IRI could parsed successfully when the suffix is
separating the IRI at a component. However, detecting this requires
more effort. Maybe this feature will be implemented (by you?) in a
future release of sophia
.
pub fn write_fmt<W>(&self, w: &mut W) -> Result where
W: Write,
[src]
W: Write,
Writes the IRI 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 IRI to the io::Write
using the N3 syntax.
Trait Implementations
impl<TD: Clone + TermData> Clone for Iri<TD>
[src]
impl<TD: Copy + TermData> Copy for Iri<TD>
[src]
impl<TD: Debug + TermData> Debug for Iri<TD>
[src]
impl<TD> Display for Iri<TD> where
TD: TermData,
[src]
TD: TermData,
impl<TD: Eq + TermData> Eq for Iri<TD>
[src]
impl<'a> From<Iri<&'a str>> for SimpleIri<'a>
[src]
impl<TD> From<Iri<TD>> for Term<TD> where
TD: TermData,
[src]
TD: TermData,
impl<TD> From<Namespace<TD>> for Iri<TD> where
TD: TermData,
[src]
TD: TermData,
impl<'a, TD> From<SimpleIri<'a>> for Iri<TD> where
TD: TermData + From<&'a str>,
[src]
TD: TermData + From<&'a str>,
impl<TD> Hash for Iri<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 + TermData> Ord for Iri<TD>
[src]
fn cmp(&self, other: &Iri<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 Iri<TD> where
TD: TermData,
TE: TTerm,
[src]
TD: TermData,
TE: TTerm,
impl<TD, TE: ?Sized> PartialOrd<TE> for Iri<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 Iri<TD>, Iri<MownStr<'a>>> for IriParsed<'b> where
TD: TermData,
[src]
TD: TermData,
impl<'a, 'b> Resolve<Iri<&'a str>, Iri<MownStr<'a>>> for IriParsed<'b>
[src]
impl<TD: TermData> StructuralEq for Iri<TD>
[src]
impl<TD: TermData> TTerm for Iri<TD>
[src]
fn kind(&self) -> TermKind
[src]
fn value_raw(&self) -> RawValue<'_>
[src]
fn as_dyn(&self) -> &dyn TTerm
[src]
fn value(&self) -> MownStr<'_>
[src]
fn datatype(&self) -> Option<SimpleIri<'_>>
[src]
fn language(&self) -> Option<&str>
[src]
fn is_absolute(&self) -> bool
[src]
impl<TD> TryCopyTerm for Iri<TD> where
TD: TermData + for<'x> From<&'x str>,
[src]
TD: TermData + for<'x> From<&'x str>,
type Error = TermError
The error type produced when failing to copy a given term
fn try_copy<T: ?Sized>(term: &T) -> Result<Self, Self::Error> where
T: TTerm,
[src]
T: TTerm,
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<TD> TryFrom<Iri<TD>> for Namespace<TD> where
TD: TermData,
[src]
TD: TermData,
type Error = TermError
The type returned in the event of a conversion error.
fn try_from(iri: Iri<TD>) -> Result<Self, Self::Error>
[src]
Requires that the given Iri
has no suffix. This can be enforced with
the clone_no_suffix()
method.
impl<TD> TryFrom<Term<TD>> for Iri<TD> where
TD: TermData,
[src]
TD: TermData,
Auto Trait Implementations
impl<TD> RefUnwindSafe for Iri<TD> where
TD: RefUnwindSafe,
TD: RefUnwindSafe,
impl<TD> Send for Iri<TD> where
TD: Send,
TD: Send,
impl<TD> Sync for Iri<TD> where
TD: Sync,
TD: Sync,
impl<TD> Unpin for Iri<TD> where
TD: Unpin,
TD: Unpin,
impl<TD> UnwindSafe for Iri<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>,