Skip to main content

define

Function define 

Source
pub async fn define<'a, N, L, W>(
    env: Environment<'a, N, L, W>,
    active_context: &'a mut Context<N::Iri, N::BlankId>,
    local_context: &'a Merged<'a>,
    term: KeyOrKeywordRef<'a>,
    defined: &'a mut DefinedTerms,
    remote_contexts: ProcessingStack<N::Iri>,
    base_url: Option<N::Iri>,
    protected: bool,
    options: Options,
) -> Result<(), Error<L::Error>>
where N: VocabularyMut, N::Iri: Clone + Eq + Hash, N::BlankId: Clone + PartialEq, L: Loader, W: WarningHandler<N>,
Expand description

Runs the create term definition algorithm for term, adding the resulting definition to active_context.

Reads term’s entry from local_context, resolves its @id, @reverse, @type, @container, @index, @context, @language, @direction, @nest and @prefix, and installs the definition. Recurses through expand_iri_with for terms this one depends on, using defined to detect cycles; a term already defined is a no-op.

base_url is what a scoped @context inside the definition resolves its own references against. protected is the context-wide @protected default, which an explicit @protected in the term definition overrides. Whether a previously protected definition may be replaced is governed by options.override_protected.

§Errors

Returns an error when a term definition is cyclic, protected and being redefined, or otherwise invalid, and propagates loader errors for remote contexts.