json-ld 0.22.0

JSON-LD implementation
Documentation
use rdf_syntax::Iri;

use crate::{
	algorithms::expansion::JsonLdExpansionOptions,
	context::{JsonLdProcessedTermDefinitionRef, RawJsonLdProcessedContext},
};

/// Expander.
pub(crate) struct Expander<'a> {
	pub base_url: Option<&'a Iri>,
	pub options: JsonLdExpansionOptions,
	pub active_context: &'a RawJsonLdProcessedContext,
	pub active_property: Option<&'a str>,
}

impl<'a> Expander<'a> {
	pub fn active_property_definition(&self) -> Option<JsonLdProcessedTermDefinitionRef<'_>> {
		self.active_property
			.and_then(|t| self.active_context.get(t))
	}

	// pub fn warn(&mut self, w: Warning) {
	// 	(self.on_warning)(w)
	// }

	pub fn with_active_context<'b>(
		&'b self,
		active_context: &'b RawJsonLdProcessedContext,
	) -> Expander<'b> {
		Expander {
			// loader: &mut *self.loader,
			// on_warning: &mut *self.on_warning,
			base_url: self.base_url,
			options: self.options,
			active_context,
			active_property: self.active_property,
		}
	}

	pub fn with_active_property<'b>(&'b self, active_property: Option<&'b str>) -> Expander<'b> {
		Expander {
			// loader: &mut *self.loader,
			// on_warning: &mut *self.on_warning,
			base_url: self.base_url,
			options: self.options,
			active_context: self.active_context,
			active_property,
		}
	}

	pub fn with_active_context_and_property<'b>(
		&'b self,
		active_context: &'b RawJsonLdProcessedContext,
		active_property: Option<&'b str>,
	) -> Expander<'b> {
		Expander {
			// loader: &mut *self.loader,
			// on_warning: &mut *self.on_warning,
			base_url: self.base_url,
			options: self.options,
			active_context,
			active_property,
		}
	}
}