pub struct Namespace<T: Borrow<str>>(/* private fields */);
Expand description
A custom namespace.
The get
method can be used to create a new IRI by concatenating a suffix to this namespace’s IRI.
Implementations§
Source§impl<T: Borrow<str>> Namespace<T>
impl<T: Borrow<str>> Namespace<T>
Sourcepub fn new(iri: T) -> Result<Self, InvalidIri>
pub fn new(iri: T) -> Result<Self, InvalidIri>
Build a custom namespace based on the given IRI.
iri
must be a valid IRI, otherwise this constructor returns an error.
Sourcepub fn new_unchecked(iri: T) -> Self
pub fn new_unchecked(iri: T) -> Self
Build a custom namespace based on the given IRI, without checking that it is valid. If it is not, it may result in undefined behaviour.
Sourcepub fn get<'s>(&'s self, suffix: &'s str) -> Result<NsTerm<'s>, InvalidIri>
pub fn get<'s>(&'s self, suffix: &'s str) -> Result<NsTerm<'s>, InvalidIri>
Build an IRI by appending suffix
to this namespace.
Return an error if the concatenation produces an invalid IRI.
Sourcepub fn get_unchecked<'s>(&'s self, suffix: &'s str) -> NsTerm<'s>
pub fn get_unchecked<'s>(&'s self, suffix: &'s str) -> NsTerm<'s>
Build an IRI by appending suffix
to this namespace,
without checking that the resulting IRI is valid.
If it is not, it may result in undefined behaviour.
Methods from Deref<Target = IriRef<T>>§
Sourcepub fn resolve<U>(&self, rel: U) -> IriRef<String>where
U: IsIriRef,
pub fn resolve<U>(&self, rel: U) -> IriRef<String>where
U: IsIriRef,
Resolve a relative IRI reference against this one.
NB: when resolving multiple IRI references against the same base,
it is preferable to first turn it into a BaseIriRef
,
with the IriRef::as_base
or IriRef::to_base
methods.
Sourcepub fn as_base(&self) -> BaseIriRef<&str>
pub fn as_base(&self) -> BaseIriRef<&str>
Borrow this IRI as a BaseIriRef
providing more efficient and flexible resolution methods than IriRef::resolve
.