pub struct ContextResolver {
pub vocab: Option<String>,
pub prefixes: HashMap<String, String>,
pub terms: HashMap<String, TermDef>,
}Expand description
A resolved JSON-LD context that maps short terms to full IRIs.
Fields§
§vocab: Option<String>@vocab — default IRI prefix for unmapped terms
prefixes: HashMap<String, String>prefix:suffix mappings (e.g., “oo” -> “https://…#”)
terms: HashMap<String, TermDef>Direct term mappings (e.g., “Class” -> TermDef { iri, type_coercion })
Implementations§
Source§impl ContextResolver
impl ContextResolver
pub fn new() -> Self
Sourcepub fn from_context_value(
context_value: &Value,
known_contexts: &HashMap<String, Value>,
) -> Result<Self>
pub fn from_context_value( context_value: &Value, known_contexts: &HashMap<String, Value>, ) -> Result<Self>
Parse a JSON-LD @context value and build the resolver.
known_contexts maps context IRIs to their parsed JSON content (from ModuleState.contexts).
Sourcepub fn expand_term(&self, term: &str) -> String
pub fn expand_term(&self, term: &str) -> String
Expand a compacted term to a full IRI. E.g., “Class” -> “oo:Class” -> “https://…#Class” Or “oo:Class” -> “https://…#Class” Handles chained prefixes like “clv:x” -> “npmd:pkg/x” -> “https://…/pkg/x”
Sourcepub fn compact_iri(&self, iri: &str) -> String
pub fn compact_iri(&self, iri: &str) -> String
Compact a full IRI back to a prefixed form. Returns the shortest representation: tries exact term matches first, then prefix matches, then @vocab, falling back to the original IRI.
Trait Implementations§
Source§impl Clone for ContextResolver
impl Clone for ContextResolver
Source§fn clone(&self) -> ContextResolver
fn clone(&self) -> ContextResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more