Skip to main content

keyword_alias

Function keyword_alias 

Source
pub fn keyword_alias<'a, N>(
    vocabulary: &N,
    active_context: &'a Context<N::Iri, N::BlankId>,
    options: Options,
    k: Keyword,
) -> &'a str
where N: Vocabulary, N::Iri: Clone + Hash + Eq, N::BlankId: Clone + Hash + Eq,
Expand description

Returns the key a keyword compacts to under the active context, which is either an alias the context defines for it or the keyword itself.

Restricted to the keywords compaction emits (see CACHED_KEYWORDS). All of their aliases are resolved on first use through compact_iri and cached on the active context, once per processing mode, so that the many keyword call sites throughout compaction cost a slice index instead of a lock, a hash lookup and a run of the IRI compaction algorithm.

A keyword with no alias falls back to its own spelling rather than to None, so callers always get a usable key.

Compaction emits @id, @type, @value, @language, @direction, @index, @list, @graph, @included, @reverse, @set, @json and @none; any other keyword is returned as spelled, without consulting the active context.