Skip to main content

json_ld/algorithms/context_processing/
options.rs

1use crate::JsonLdProcessingMode;
2
3/// Options of the Context Processing Algorithm.
4#[derive(Clone, Copy, PartialEq, Eq)]
5pub struct JsonLdContextProcessingOptions {
6	/// The processing mode
7	pub processing_mode: JsonLdProcessingMode,
8
9	/// Override protected definitions.
10	pub override_protected: bool,
11
12	/// Propagate the processed context.
13	pub propagate: bool,
14}
15
16impl JsonLdContextProcessingOptions {
17	/// Return the same set of options, but with `override_protected` set to `true`.
18	#[must_use]
19	pub fn with_override(&self) -> JsonLdContextProcessingOptions {
20		let mut opt = *self;
21		opt.override_protected = true;
22		opt
23	}
24
25	/// Return the same set of options, but with `override_protected` set to `false`.
26	#[must_use]
27	pub fn with_no_override(&self) -> JsonLdContextProcessingOptions {
28		let mut opt = *self;
29		opt.override_protected = false;
30		opt
31	}
32
33	/// Return the same set of options, but with `propagate` set to `false`.
34	#[must_use]
35	pub fn without_propagation(&self) -> JsonLdContextProcessingOptions {
36		let mut opt = *self;
37		opt.propagate = false;
38		opt
39	}
40}
41
42impl Default for JsonLdContextProcessingOptions {
43	fn default() -> JsonLdContextProcessingOptions {
44		JsonLdContextProcessingOptions {
45			processing_mode: JsonLdProcessingMode::default(),
46			override_protected: false,
47			propagate: true,
48		}
49	}
50}