pub struct PrefixCache { /* private fields */ }Expand description
Bidirectional namespace prefix ↔ IRI lookup cache.
Stores the registered prefix→IRI mappings and provides fast lookups in both directions (prefix→IRI and IRI→prefix).
Implementations§
Source§impl PrefixCache
impl PrefixCache
pub fn new() -> Self
Sourcepub fn register(&mut self, prefix: &str, iri: &str)
pub fn register(&mut self, prefix: &str, iri: &str)
Register a new prefix → IRI mapping.
Replaces any existing mapping for the same prefix.
Sourcepub fn resolve_prefix(&self, prefix: &str) -> Option<&str>
pub fn resolve_prefix(&self, prefix: &str) -> Option<&str>
Look up the IRI for a given prefix. Returns None if not registered.
Sourcepub fn resolve_iri(&self, iri: &str) -> Option<&str>
pub fn resolve_iri(&self, iri: &str) -> Option<&str>
Look up the prefix for a given namespace IRI. Returns None if not registered.
Sourcepub fn expand(&self, prefixed: &str) -> Option<String>
pub fn expand(&self, prefixed: &str) -> Option<String>
Expand a prefixed name (e.g. "rdf:type") to a full IRI.
Returns None if the prefix is not registered or the input has no colon.
Sourcepub fn compact(&self, iri: &str) -> Option<String>
pub fn compact(&self, iri: &str) -> Option<String>
Compact a full IRI to a prefixed name (e.g. "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" → "rdf:type").
Tries all registered namespaces; picks the longest matching namespace.
pub fn is_empty(&self) -> bool
Sourcepub fn with_standard_prefixes(self) -> Self
pub fn with_standard_prefixes(self) -> Self
Register the standard RDF/RDFS/OWL/XSD prefixes.
Trait Implementations§
Source§impl Clone for PrefixCache
impl Clone for PrefixCache
Source§fn clone(&self) -> PrefixCache
fn clone(&self) -> PrefixCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PrefixCache
impl Debug for PrefixCache
Source§impl Default for PrefixCache
impl Default for PrefixCache
Source§fn default() -> PrefixCache
fn default() -> PrefixCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PrefixCache
impl RefUnwindSafe for PrefixCache
impl Send for PrefixCache
impl Sync for PrefixCache
impl Unpin for PrefixCache
impl UnsafeUnpin for PrefixCache
impl UnwindSafe for PrefixCache
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more