pub struct PrefixMap {
pub map: IndexMap<String, IriS>,
/* private fields */
}Expand description
Contains declarations of prefix maps which are used in TURTLE, SPARQL and ShEx
Fields§
§map: IndexMap<String, IriS>Implementations§
Source§impl PrefixMap
Methods for PrefixMap manipulation
impl PrefixMap
Methods for PrefixMap manipulation
Sourcepub fn add_prefix<A, I>(
&mut self,
alias: A,
iri: I,
) -> Result<(), PrefixMapError>
pub fn add_prefix<A, I>( &mut self, alias: A, iri: I, ) -> Result<(), PrefixMapError>
Inserts an alias association to an IRI
Sourcepub fn from_hashmap(
hm: HashMap<&str, &str>,
) -> Result<PrefixMap, PrefixMapError>
pub fn from_hashmap( hm: HashMap<&str, &str>, ) -> Result<PrefixMap, PrefixMapError>
Source§impl PrefixMap
Formatting for PrefixMap outputs
impl PrefixMap
Formatting for PrefixMap outputs
Sourcepub fn without_colors(self) -> Self
pub fn without_colors(self) -> Self
Disable all colors when qualifying IRIs
Sourcepub fn without_default_colors(self) -> Self
pub fn without_default_colors(self) -> Self
Use default colors when qualifying IRIs
Sourcepub fn with_hyperlink(self, hyperlink: bool) -> Self
pub fn with_hyperlink(self, hyperlink: bool) -> Self
Enable or disable hyperlinking when qualifying IRIs
Sourcepub fn with_qualify_prefix_color(self, color: Option<Color>) -> Self
pub fn with_qualify_prefix_color(self, color: Option<Color>) -> Self
Change color when qualifying a IRI
Sourcepub fn with_qualify_localname_color(self, color: Option<Color>) -> Self
pub fn with_qualify_localname_color(self, color: Option<Color>) -> Self
Change color of localname when qualifying a IRI
Sourcepub fn with_qualify_semicolon_color(self, color: Option<Color>) -> Self
pub fn with_qualify_semicolon_color(self, color: Option<Color>) -> Self
Change color of semicolon when qualifying a IRI
Sourcepub fn without_rich_qualifying(self) -> Self
pub fn without_rich_qualifying(self) -> Self
Disable all rich qualifying (colors and hyperlinks)
Source§impl PrefixMap
Qualifying IRIs against a PrefixMap
impl PrefixMap
Qualifying IRIs against a PrefixMap
Sourcepub fn qualify(&self, iri: &IriS) -> String
pub fn qualify(&self, iri: &IriS) -> String
Qualifies an IRI against a PrefixMap
If it can’t qualify the IRI, it returns the iri between < and >
let pm = PrefixMap::from_hashmap(
HashMap::from([
("", "https://example.org/"),
("schema", "https://schema.org/")])
)?;
let a = IriS::from_str("https://example.org/a")?;
assert_eq!(pm.qualify(&a), ":a");
let knows = IriS::from_str("https://schema.org/knows")?;
assert_eq!(pm.qualify(&knows), "schema:knows");
let other = IriS::from_str("https://other.org/foo")?;
assert_eq!(pm.qualify(&other), "<https://other.org/foo>");Sourcepub fn qualify_optional(&self, iri: &IriS) -> Option<String>
pub fn qualify_optional(&self, iri: &IriS) -> Option<String>
Qualifies an IRI against a PrefixMap
If it can’t qualify the IRI, returns None
let pm = PrefixMap::from_hashmap(
HashMap::from([
("", "https://example.org/"),
("schema", "https://schema.org/")])
)?;
let a = IriS::from_str("https://example.org/a")?;
assert_eq!(pm.qualify_optional(&a), Some(":a".to_string()));
let knows = IriS::from_str("https://schema.org/knows")?;
assert_eq!(pm.qualify_optional(&knows), Some("schema:knows".to_string()));
let other = IriS::from_str("https://other.org/foo")?;
assert_eq!(pm.qualify_optional(&other), None);Sourcepub fn qualify_and_length(&self, iri: &IriS) -> (String, usize)
pub fn qualify_and_length(&self, iri: &IriS) -> (String, usize)
Qualifies an IRI against a PrefixMap, returning the length of the qualified string
let pm = PrefixMap::from_hashmap(
HashMap::from([
("", "https://example.org/"),
("schema", "https://schema.org/")])
)?;
let a = IriS::from_str("https://example.org/a")?;
assert_eq!(pm.qualify_and_length(&a), (":a".to_string(), 2));
let knows = IriS::from_str("https://schema.org/knows")?;
assert_eq!(pm.qualify_and_length(&knows), ("schema:knows".to_string(),12));
let other = IriS::from_str("https://other.org/foo")?;
assert_eq!(pm.qualify_and_length(&other), ("<https://other.org/foo>".to_string(), 23));Sourcepub fn qualify_local(&self, iri: &IriS) -> Option<String>
pub fn qualify_local(&self, iri: &IriS) -> Option<String>
Qualify an IRI against a PrefixMap and obtains the local name.
Returns None if it can’t qualify the IRI.
let pm = PrefixMap::from_hashmap(
HashMap::from([
("", "https://example.org/"),
("schema", "https://schema.org/")])
)?;
let a = IriS::from_str("https://example.org/a")?;
assert_eq!(pm.qualify_local(&a), Some("a".to_string()));
let knows = IriS::from_str("https://schema.org/knows")?;
assert_eq!(pm.qualify_local(&knows), Some("knows".to_string()));
let other = IriS::from_str("https://other.org/foo")?;
assert_eq!(pm.qualify_local(&other), None);Source§impl PrefixMap
Resolving strings and IRI references against a PrefixMap
impl PrefixMap
Resolving strings and IRI references against a PrefixMap
Sourcepub fn resolve(&self, str: &str) -> Result<IriS, PrefixMapError>
pub fn resolve(&self, str: &str) -> Result<IriS, PrefixMapError>
Resolves a string against a prefix map
Returns an error if the prefix is not found in the prefix map or if the string is not a valid IRI.
Example: Given a string like “ex:a” and a prefixmap that has alias “ex” with value “https://example.org/”, the result will be “https://example.org/a”
let pm: PrefixMap = PrefixMap::from_hashmap(
HashMap::from([
("", "https://example.org/"),
("schema", "https://schema.org/")])
)?;
let a = pm.resolve(":a")?;
let a_resolved = IriS::from_str("https://example.org/a")?;
assert_eq!(a, a_resolved);
let knows = pm.resolve("schema:knows")?;
let knows_resolved = IriS::from_str("https://schema.org/knows")?;
assert_eq!(knows, knows_resolved);Sourcepub fn resolve_iriref(&self, iri_ref: IriRef) -> Result<IriS, PrefixMapError>
pub fn resolve_iriref(&self, iri_ref: IriRef) -> Result<IriS, PrefixMapError>
Sourcepub fn resolve_prefix_local<S: Into<String>>(
&self,
prefix: S,
local: S,
) -> Result<IriS, PrefixMapError>
pub fn resolve_prefix_local<S: Into<String>>( &self, prefix: S, local: S, ) -> Result<IriS, PrefixMapError>
Resolves a prefixed alias and a local name in a prefix map to obtain the full IRI
Returns an error if:
- the prefix is not found in the prefix map.
- the resulting IRI is invalid.
let pm = PrefixMap::from_hashmap(
HashMap::from([
("", "https://example.org/"),
("schema", "https://schema.org/"),
("xsd", "https://www.w3.org/2001/XMLSchema#")
]))?;
let a = pm.resolve_prefix_local("", "a")?;
let a_resolved = IriS::from_str("https://example.org/a")?;
assert_eq!(a, a_resolved);
let knows = pm.resolve_prefix_local("schema","knows")?;
let knows_resolved = IriS::from_str("https://schema.org/knows")?;
assert_eq!(knows, knows_resolved);
let xsd_string = pm.resolve_prefix_local("xsd","string")?;
let xsd_string_resolved = IriS::from_str("https://www.w3.org/2001/XMLSchema#string")?;
assert_eq!(xsd_string, xsd_string_resolved);Trait Implementations§
Source§impl<'de> Deserialize<'de> for PrefixMap
impl<'de> Deserialize<'de> for PrefixMap
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Iterator for PrefixMap
impl Iterator for PrefixMap
Source§fn next(&mut self) -> Option<Self::Item>
fn next(&mut self) -> Option<Self::Item>
Source§fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
iter_next_chunk)N values. Read more1.0.0 · Source§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
1.0.0 · Source§fn count(self) -> usizewhere
Self: Sized,
fn count(self) -> usizewhere
Self: Sized,
1.0.0 · Source§fn last(self) -> Option<Self::Item>where
Self: Sized,
fn last(self) -> Option<Self::Item>where
Self: Sized,
Source§fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
iter_advance_by)n elements. Read more1.0.0 · Source§fn nth(&mut self, n: usize) -> Option<Self::Item>
fn nth(&mut self, n: usize) -> Option<Self::Item>
nth element of the iterator. Read more1.28.0 · Source§fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
1.0.0 · Source§fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
1.0.0 · Source§fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
Self: Sized,
U: IntoIterator,
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
Self: Sized,
U: IntoIterator,
Source§fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
iter_intersperse)separator between adjacent
items of the original iterator. Read moreSource§fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
iter_intersperse)separator
between adjacent items of the original iterator. Read more1.0.0 · Source§fn map<B, F>(self, f: F) -> Map<Self, F>
fn map<B, F>(self, f: F) -> Map<Self, F>
1.0.0 · Source§fn filter<P>(self, predicate: P) -> Filter<Self, P>
fn filter<P>(self, predicate: P) -> Filter<Self, P>
1.0.0 · Source§fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
1.0.0 · Source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
1.0.0 · Source§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
1.0.0 · Source§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
1.57.0 · Source§fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
1.0.0 · Source§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n elements. Read more1.0.0 · Source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n elements, or fewer
if the underlying iterator ends sooner. Read more1.0.0 · Source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
1.29.0 · Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
iter_map_windows)f for each contiguous window of size N over
self and returns an iterator over the outputs of f. Like slice::windows(),
the windows during mapping overlap as well. Read more1.0.0 · Source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Iterator. Read moreSource§fn try_collect<B>(
&mut self,
) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
fn try_collect<B>( &mut self, ) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
iterator_try_collect)Source§fn collect_into<E>(self, collection: &mut E) -> &mut E
fn collect_into<E>(self, collection: &mut E) -> &mut E
iter_collect_into)1.0.0 · Source§fn partition<B, F>(self, f: F) -> (B, B)
fn partition<B, F>(self, f: F) -> (B, B)
Source§fn is_partitioned<P>(self, predicate: P) -> bool
fn is_partitioned<P>(self, predicate: P) -> bool
iter_is_partitioned)true precede all those that return false. Read more1.27.0 · Source§fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
1.27.0 · Source§fn try_for_each<F, R>(&mut self, f: F) -> R
fn try_for_each<F, R>(&mut self, f: F) -> R
1.0.0 · Source§fn fold<B, F>(self, init: B, f: F) -> B
fn fold<B, F>(self, init: B, f: F) -> B
1.51.0 · Source§fn reduce<F>(self, f: F) -> Option<Self::Item>
fn reduce<F>(self, f: F) -> Option<Self::Item>
Source§fn try_reduce<R>(
&mut self,
f: impl FnMut(Self::Item, Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
fn try_reduce<R>( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
iterator_try_reduce)1.0.0 · Source§fn all<F>(&mut self, f: F) -> bool
fn all<F>(&mut self, f: F) -> bool
1.0.0 · Source§fn any<F>(&mut self, f: F) -> bool
fn any<F>(&mut self, f: F) -> bool
1.0.0 · Source§fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
1.30.0 · Source§fn find_map<B, F>(&mut self, f: F) -> Option<B>
fn find_map<B, F>(&mut self, f: F) -> Option<B>
Source§fn try_find<R>(
&mut self,
f: impl FnMut(&Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
fn try_find<R>( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
try_find)1.0.0 · Source§fn position<P>(&mut self, predicate: P) -> Option<usize>
fn position<P>(&mut self, predicate: P) -> Option<usize>
1.0.0 · Source§fn max(self) -> Option<Self::Item>
fn max(self) -> Option<Self::Item>
1.0.0 · Source§fn min(self) -> Option<Self::Item>
fn min(self) -> Option<Self::Item>
1.6.0 · Source§fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 · Source§fn max_by<F>(self, compare: F) -> Option<Self::Item>
fn max_by<F>(self, compare: F) -> Option<Self::Item>
1.6.0 · Source§fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 · Source§fn min_by<F>(self, compare: F) -> Option<Self::Item>
fn min_by<F>(self, compare: F) -> Option<Self::Item>
1.0.0 · Source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
1.36.0 · Source§fn copied<'a, T>(self) -> Copied<Self>
fn copied<'a, T>(self) -> Copied<Self>
Source§fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
Self: Sized,
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
Self: Sized,
iter_array_chunks)N elements of the iterator at a time. Read more1.11.0 · Source§fn product<P>(self) -> P
fn product<P>(self) -> P
Source§fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
iter_order_by)Iterator with those
of another with respect to the specified comparison function. Read more1.5.0 · Source§fn partial_cmp<I>(self, other: I) -> Option<Ordering>
fn partial_cmp<I>(self, other: I) -> Option<Ordering>
PartialOrd elements of
this Iterator with those of another. The comparison works like short-circuit
evaluation, returning a result without comparing the remaining elements.
As soon as an order can be determined, the evaluation stops and a result is returned. Read moreSource§fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
iter_order_by)Iterator with those
of another with respect to the specified comparison function. Read moreSource§fn eq_by<I, F>(self, other: I, eq: F) -> bool
fn eq_by<I, F>(self, other: I, eq: F) -> bool
iter_order_by)1.5.0 · Source§fn lt<I>(self, other: I) -> bool
fn lt<I>(self, other: I) -> bool
Iterator are lexicographically
less than those of another. Read more1.5.0 · Source§fn le<I>(self, other: I) -> bool
fn le<I>(self, other: I) -> bool
Iterator are lexicographically
less or equal to those of another. Read more1.5.0 · Source§fn gt<I>(self, other: I) -> bool
fn gt<I>(self, other: I) -> bool
Iterator are lexicographically
greater than those of another. Read more1.5.0 · Source§fn ge<I>(self, other: I) -> bool
fn ge<I>(self, other: I) -> bool
Iterator are lexicographically
greater than or equal to those of another. Read more1.82.0 · Source§fn is_sorted(self) -> bool
fn is_sorted(self) -> bool
1.82.0 · Source§fn is_sorted_by<F>(self, compare: F) -> bool
fn is_sorted_by<F>(self, compare: F) -> bool
1.82.0 · Source§fn is_sorted_by_key<F, K>(self, f: F) -> bool
fn is_sorted_by_key<F, K>(self, f: F) -> bool
impl Eq for PrefixMap
impl StructuralPartialEq for PrefixMap
Auto Trait Implementations§
impl Freeze for PrefixMap
impl RefUnwindSafe for PrefixMap
impl Send for PrefixMap
impl Sync for PrefixMap
impl Unpin for PrefixMap
impl UnsafeUnpin for PrefixMap
impl UnwindSafe for PrefixMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<I> IntoIterator for Iwhere
I: Iterator,
impl<I> IntoIterator for Iwhere
I: Iterator,
Source§impl<I> IteratorRandom for Iwhere
I: Iterator,
impl<I> IteratorRandom for Iwhere
I: Iterator,
Source§fn choose_stable<R>(self, rng: &mut R) -> Option<Self::Item>
fn choose_stable<R>(self, rng: &mut R) -> Option<Self::Item>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.