Skip to main content

json_ld/core/object/
mod.rs

1//! Nodes, lists and values.
2use btree_indexmap::BTreeIndexMultiSet;
3use educe::Educe;
4use json_syntax::JsonNumber;
5use langtag::LangTag;
6use rdf_syntax::Id;
7use rdf_syntax::Iri;
8use std::hash::Hash;
9
10use crate::syntax::JsonLdKeyword;
11use crate::{JsonLdIndexed, JsonLdLenient, JsonLdVisit};
12
13pub mod list;
14pub mod node;
15mod typ;
16pub mod value;
17
18pub use list::JsonLdList;
19pub use node::{JsonLdGraph, JsonLdIndexedNode, JsonLdNode, JsonLdNodes};
20pub use value::{JsonLdLiteralValue, JsonLdValue};
21
22use typ::JsonLdObjectTypeRef;
23
24/// Abstract object.
25pub trait AnyJsonLdObject {
26	fn as_ref(&self) -> JsonLdObjectRef<'_>;
27
28	#[inline]
29	fn id(&self) -> Option<&JsonLdLenient<Id>> {
30		match self.as_ref() {
31			JsonLdObjectRef::Node(n) => n.id.as_ref(),
32			_ => None,
33		}
34	}
35
36	#[inline]
37	fn language(&self) -> Option<JsonLdLenient<&LangTag>> {
38		match self.as_ref() {
39			JsonLdObjectRef::Value(value) => value.language(),
40			_ => None,
41		}
42	}
43
44	#[inline]
45	fn is_value(&self) -> bool {
46		matches!(self.as_ref(), JsonLdObjectRef::Value(_))
47	}
48
49	#[inline]
50	fn is_node(&self) -> bool {
51		matches!(self.as_ref(), JsonLdObjectRef::Node(_))
52	}
53
54	#[inline]
55	fn is_graph(&self) -> bool {
56		match self.as_ref() {
57			JsonLdObjectRef::Node(n) => n.is_graph(),
58			_ => false,
59		}
60	}
61
62	#[inline]
63	fn is_list(&self) -> bool {
64		matches!(self.as_ref(), JsonLdObjectRef::List(_))
65	}
66}
67
68/// Object reference.
69pub enum JsonLdObjectRef<'a> {
70	/// Value object.
71	Value(&'a JsonLdValue),
72
73	/// Node object.
74	Node(&'a JsonLdNode),
75
76	/// List object.
77	List(&'a JsonLdList),
78}
79
80pub enum JsonLdObjectMut<'a> {
81	Value(&'a mut JsonLdValue),
82
83	Node(&'a mut JsonLdNode),
84
85	List(&'a mut JsonLdList),
86}
87
88impl<'a> JsonLdObjectMut<'a> {
89	pub fn reborrow(&mut self) -> JsonLdObjectMut<'_> {
90		match self {
91			Self::Value(v) => JsonLdObjectMut::Value(v),
92			Self::Node(n) => JsonLdObjectMut::Node(n),
93			Self::List(l) => JsonLdObjectMut::List(l),
94		}
95	}
96}
97
98/// Indexed object.
99pub type JsonLdIndexedObject = JsonLdIndexed<JsonLdObject>;
100
101/// Object.
102///
103/// JSON-LD connects together multiple kinds of data objects.
104/// Objects may be nodes, values or lists of objects.
105///
106/// You can get a `JsonLdObject` by expanding a JSON-LD document using the
107/// expansion algorithm.
108#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
109#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
110#[cfg_attr(feature = "serde", serde(untagged))]
111pub enum JsonLdObject {
112	/// Value object.
113	Value(JsonLdValue),
114
115	/// List object.
116	List(JsonLdList),
117
118	/// Node object.
119	Node(Box<JsonLdNode>),
120}
121
122impl JsonLdObject {
123	/// Creates a `null` value object.
124	#[inline(always)]
125	pub fn null() -> Self {
126		Self::Value(JsonLdValue::null())
127	}
128
129	/// Creates a new node object from a node.
130	#[inline(always)]
131	pub fn node(n: JsonLdNode) -> Self {
132		Self::Node(Box::new(n))
133	}
134
135	/// Identifier of the object, if it is a node object.
136	#[inline(always)]
137	pub fn id(&self) -> Option<&JsonLdLenient<Id>> {
138		match self {
139			JsonLdObject::Node(n) => n.id.as_ref(),
140			_ => None,
141		}
142	}
143
144	// /// Use the given `generator` to assign an identifier to all nodes that
145	// /// don't have one.
146	// pub fn identify_all(&mut self, generator: &mut impl Generator) {
147	// 	match self {
148	// 		Object::Node(n) => n.identify_all_with(vocabulary, generator),
149	// 		Object::List(l) => {
150	// 			for object in l {
151	// 				object.identify_all_with(vocabulary, generator)
152	// 			}
153	// 		}
154	// 		_ => (),
155	// 	}
156	// }
157
158	// /// Puts this object literals into canonical form using the given
159	// /// `buffer`.
160	// ///
161	// /// The buffer is used to compute the canonical form of numbers.
162	// pub fn canonicalize_with(&mut self, buffer: &mut ryu_js::Buffer) {
163	// 	match self {
164	// 		Self::List(l) => l.canonicalize_with(buffer),
165	// 		Self::Node(n) => n.canonicalize_with(buffer),
166	// 		Self::Value(v) => v.canonicalize_with(buffer),
167	// 	}
168	// }
169
170	// /// Puts this object literals into canonical form.
171	// pub fn canonicalize(&mut self) {
172	// 	let mut buffer = ryu_js::Buffer::new();
173	// 	self.canonicalize_with(&mut buffer)
174	// }
175
176	/// Returns an iterator over the types of the object.
177	pub fn types(&self) -> JsonLdObjectTypes<'_> {
178		match self {
179			Self::Value(value) => JsonLdObjectTypes::Value(value.typ()),
180			Self::Node(node) => {
181				JsonLdObjectTypes::Node(node.types.as_ref().map(BTreeIndexMultiSet::iter))
182			}
183			Self::List(_) => JsonLdObjectTypes::List,
184		}
185	}
186
187	/// Identifier of the object as an IRI.
188	///
189	/// If the object is a node identified by an IRI, returns this IRI.
190	/// Returns `None` otherwise.
191	#[inline(always)]
192	pub fn as_iri(&self) -> Option<&Iri> {
193		match self {
194			JsonLdObject::Node(node) => node.as_iri(),
195			_ => None,
196		}
197	}
198
199	/// Tests if the object is a value.
200	#[inline(always)]
201	pub fn is_value(&self) -> bool {
202		matches!(self, JsonLdObject::Value(_))
203	}
204
205	/// Returns this object as a value, if it is one.
206	#[inline(always)]
207	pub fn as_value(&self) -> Option<&JsonLdValue> {
208		match self {
209			Self::Value(v) => Some(v),
210			_ => None,
211		}
212	}
213
214	/// Returns this object as a mutable value, if it is one.
215	#[inline(always)]
216	pub fn as_value_mut(&mut self) -> Option<&mut JsonLdValue> {
217		match self {
218			Self::Value(v) => Some(v),
219			_ => None,
220		}
221	}
222
223	/// Converts this object as a value, if it is one.
224	#[inline(always)]
225	pub fn into_value(self) -> Option<JsonLdValue> {
226		match self {
227			Self::Value(v) => Some(v),
228			_ => None,
229		}
230	}
231
232	/// Tests if the object is a node.
233	#[inline(always)]
234	pub fn is_node(&self) -> bool {
235		matches!(self, JsonLdObject::Node(_))
236	}
237
238	/// Returns this object as a node, if it is one.
239	#[inline(always)]
240	pub fn as_node(&self) -> Option<&JsonLdNode> {
241		match self {
242			Self::Node(n) => Some(n),
243			_ => None,
244		}
245	}
246
247	/// Returns this object as a mutable node, if it is one.
248	#[inline(always)]
249	pub fn as_node_mut(&mut self) -> Option<&mut JsonLdNode> {
250		match self {
251			Self::Node(n) => Some(n),
252			_ => None,
253		}
254	}
255
256	/// Converts this object into a node, if it is one.
257	#[inline(always)]
258	pub fn into_node(self) -> Option<JsonLdNode> {
259		match self {
260			Self::Node(n) => Some(*n),
261			_ => None,
262		}
263	}
264
265	/// Tests if the object is a graph object (a node with a `@graph` field).
266	#[inline(always)]
267	pub fn is_graph(&self) -> bool {
268		match self {
269			JsonLdObject::Node(n) => n.is_graph(),
270			_ => false,
271		}
272	}
273
274	/// Tests if the object is a list.
275	#[inline(always)]
276	pub fn is_list(&self) -> bool {
277		matches!(self, JsonLdObject::List(_))
278	}
279
280	/// Returns this object as a list, if it is one.
281	#[inline(always)]
282	pub fn as_list(&self) -> Option<&JsonLdList> {
283		match self {
284			Self::List(l) => Some(l),
285			_ => None,
286		}
287	}
288
289	/// Returns this object as a mutable list, if it is one.
290	#[inline(always)]
291	pub fn as_list_mut(&mut self) -> Option<&mut JsonLdList> {
292		match self {
293			Self::List(l) => Some(l),
294			_ => None,
295		}
296	}
297
298	/// Converts this object into a list, if it is one.
299	#[inline(always)]
300	pub fn into_list(self) -> Option<JsonLdList> {
301		match self {
302			Self::List(l) => Some(l),
303			_ => None,
304		}
305	}
306
307	/// Get the object as a string.
308	///
309	/// If the object is a value that is a string, returns this string.
310	/// If the object is a node that is identified, returns the identifier as a string.
311	/// Returns `None` otherwise.
312	#[inline(always)]
313	pub fn as_str(&self) -> Option<&str> {
314		match self {
315			JsonLdObject::Value(value) => value.as_str(),
316			JsonLdObject::Node(node) => node.as_str(),
317			_ => None,
318		}
319	}
320
321	/// Get the value as a boolean, if it is.
322	#[inline(always)]
323	pub fn as_bool(&self) -> Option<bool> {
324		match self {
325			JsonLdObject::Value(value) => value.as_bool(),
326			_ => None,
327		}
328	}
329
330	/// Get the value as a number, if it is.
331	#[inline(always)]
332	pub fn as_number(&self) -> Option<&JsonNumber> {
333		match self {
334			JsonLdObject::Value(value) => value.as_number(),
335			_ => None,
336		}
337	}
338
339	/// If the object is a language-tagged value,
340	/// Return its associated language.
341	#[inline(always)]
342	pub fn language(&self) -> Option<JsonLdLenient<&LangTag>> {
343		match self {
344			JsonLdObject::Value(value) => value.language(),
345			_ => None,
346		}
347	}
348
349	/// Equivalence operator.
350	///
351	/// Equivalence is different from equality for anonymous objects:
352	/// List objects and anonymous node objects have an implicit unlabeled blank nodes and thus never equivalent.
353	pub fn equivalent(&self, other: &Self) -> bool {
354		match (self, other) {
355			(Self::Value(a), Self::Value(b)) => a == b,
356			(Self::Node(a), Self::Node(b)) => a.equivalent(b),
357			_ => false,
358		}
359	}
360
361	/// Returns an iterator over the entries of JSON representation of the
362	/// object.
363	pub fn entries(&self) -> Entries<'_> {
364		match self {
365			Self::Value(value) => Entries::Value(value.entries()),
366			Self::List(list) => Entries::List(Some(list.entry())),
367			Self::Node(node) => Entries::Node(node.entries()),
368		}
369	}
370}
371
372impl JsonLdVisit for JsonLdObject {
373	fn visit_with(&self, f: &mut impl FnMut(JsonLdObjectRef)) {
374		match self {
375			Self::Value(v) => v.visit_with(f),
376			Self::List(l) => l.visit_with(f),
377			Self::Node(n) => n.visit_with(f),
378		}
379	}
380
381	fn visit_mut_with(&mut self, f: &mut impl FnMut(JsonLdObjectMut)) {
382		match self {
383			Self::Value(v) => v.visit_mut_with(f),
384			Self::List(l) => l.visit_mut_with(f),
385			Self::Node(n) => n.visit_mut_with(f),
386		}
387	}
388}
389
390impl JsonLdIndexed<JsonLdObject> {
391	pub fn equivalent(&self, other: &Self) -> bool {
392		self.index() == other.index() && self.inner().equivalent(other.inner())
393	}
394
395	/// Converts this indexed object into an indexed node, if it is one.
396	#[inline(always)]
397	pub fn into_indexed_node(self) -> Option<JsonLdIndexed<JsonLdNode>> {
398		let (object, index) = self.into_parts();
399		object
400			.into_node()
401			.map(|node| JsonLdIndexed::new(node, index))
402	}
403
404	/// Converts this indexed object into an indexed node, if it is one.
405	#[inline(always)]
406	pub fn into_indexed_value(self) -> Option<JsonLdIndexed<JsonLdValue>> {
407		let (object, index) = self.into_parts();
408		object
409			.into_value()
410			.map(|value| JsonLdIndexed::new(value, index))
411	}
412
413	/// Converts this indexed object into an indexed list, if it is one.
414	#[inline(always)]
415	pub fn into_indexed_list(self) -> Option<JsonLdIndexed<JsonLdList>> {
416		let (object, index) = self.into_parts();
417		object
418			.into_list()
419			.map(|list| JsonLdIndexed::new(list, index))
420	}
421
422	/// Try to convert this object into an unnamed graph.
423	pub fn into_unnamed_graph(self) -> Result<JsonLdGraph, Self> {
424		let (obj, index) = self.into_parts();
425		match obj {
426			JsonLdObject::Node(n) => match n.into_unnamed_graph() {
427				Ok(g) => Ok(g),
428				Err(n) => Err(JsonLdIndexed::new(JsonLdObject::node(n), index)),
429			},
430			obj => Err(JsonLdIndexed::new(obj, index)),
431		}
432	}
433
434	pub fn entries(&self) -> IndexedEntries<'_> {
435		IndexedEntries {
436			index: self.index(),
437			inner: self.inner().entries(),
438		}
439	}
440}
441
442#[derive(Educe)]
443#[educe(Clone)]
444pub enum Entries<'a> {
445	Value(value::JsonLdValueEntries<'a>),
446	List(Option<&'a [JsonLdIndexedObject]>),
447	Node(node::JsonLdNodeEntries<'a>),
448}
449
450impl<'a> Iterator for Entries<'a> {
451	type Item = JsonLdObjectEntryRef<'a>;
452
453	fn size_hint(&self) -> (usize, Option<usize>) {
454		let len = match self {
455			Self::Value(v) => v.len(),
456			Self::List(l) => usize::from(l.is_some()),
457			Self::Node(n) => n.len(),
458		};
459
460		(len, Some(len))
461	}
462
463	fn next(&mut self) -> Option<Self::Item> {
464		match self {
465			Self::Value(v) => v.next().map(JsonLdObjectEntryRef::Value),
466			Self::List(l) => l.take().map(JsonLdObjectEntryRef::List),
467			Self::Node(n) => n.next().map(JsonLdObjectEntryRef::Node),
468		}
469	}
470}
471
472impl<'a> ExactSizeIterator for Entries<'a> {}
473
474#[derive(Educe)]
475#[educe(Clone)]
476pub struct IndexedEntries<'a> {
477	index: Option<&'a str>,
478	inner: Entries<'a>,
479}
480
481impl<'a> Iterator for IndexedEntries<'a> {
482	type Item = JsonLdIndexedObjectEntryRef<'a>;
483
484	fn size_hint(&self) -> (usize, Option<usize>) {
485		let len = self.inner.len() + usize::from(self.index.is_some());
486		(len, Some(len))
487	}
488
489	fn next(&mut self) -> Option<Self::Item> {
490		self.index
491			.take()
492			.map(JsonLdIndexedObjectEntryRef::Index)
493			.or_else(|| self.inner.next().map(JsonLdIndexedObjectEntryRef::Object))
494	}
495}
496
497impl<'a> ExactSizeIterator for IndexedEntries<'a> {}
498
499#[derive(Educe, PartialEq, Eq)]
500#[educe(Clone, Copy)]
501pub enum JsonLdObjectEntryKeyRef<'a> {
502	Value(value::JsonLdValueEntryKey),
503	List,
504	Node(node::JsonLdNodeEntryKeyRef<'a>),
505}
506
507impl<'a> JsonLdObjectEntryKeyRef<'a> {
508	pub fn into_keyword(self) -> Option<JsonLdKeyword> {
509		match self {
510			Self::Value(e) => Some(e.into_keyword()),
511			Self::List => Some(JsonLdKeyword::List),
512			Self::Node(e) => e.into_keyword(),
513		}
514	}
515
516	pub fn as_keyword(&self) -> Option<JsonLdKeyword> {
517		self.into_keyword()
518	}
519
520	pub fn into_str(self) -> &'a str {
521		match self {
522			Self::Value(e) => e.into_str(),
523			Self::List => "@list",
524			Self::Node(e) => e.into_str(),
525		}
526	}
527
528	pub fn as_str(self) -> &'a str {
529		self.into_str()
530	}
531}
532
533#[derive(Educe)]
534#[educe(Clone, Copy)]
535pub enum JsonLdObjectEntryValueRef<'a> {
536	Value(value::JsonLdValueEntryRef<'a>),
537	List(&'a [JsonLdIndexedObject]),
538	Node(node::JsonLdNodeEntryValueRef<'a>),
539}
540
541#[derive(Educe)]
542#[educe(Clone, Copy)]
543pub enum JsonLdObjectEntryRef<'a> {
544	Value(value::JsonLdValueEntryRef<'a>),
545	List(&'a [JsonLdIndexedObject]),
546	Node(node::JsonLdNodeEntryRef<'a>),
547}
548
549impl<'a> JsonLdObjectEntryRef<'a> {
550	pub fn into_key(self) -> JsonLdObjectEntryKeyRef<'a> {
551		match self {
552			Self::Value(e) => JsonLdObjectEntryKeyRef::Value(e.key()),
553			Self::List(_) => JsonLdObjectEntryKeyRef::List,
554			Self::Node(e) => JsonLdObjectEntryKeyRef::Node(e.key()),
555		}
556	}
557
558	pub fn key(&self) -> JsonLdObjectEntryKeyRef<'a> {
559		self.into_key()
560	}
561
562	pub fn into_value(self) -> JsonLdObjectEntryValueRef<'a> {
563		match self {
564			Self::Value(v) => JsonLdObjectEntryValueRef::Value(v),
565			Self::List(v) => JsonLdObjectEntryValueRef::List(v),
566			Self::Node(e) => JsonLdObjectEntryValueRef::Node(e.value()),
567		}
568	}
569
570	pub fn value(&self) -> JsonLdObjectEntryValueRef<'a> {
571		self.into_value()
572	}
573
574	pub fn into_key_value(self) -> (JsonLdObjectEntryKeyRef<'a>, JsonLdObjectEntryValueRef<'a>) {
575		match self {
576			Self::Value(e) => (
577				JsonLdObjectEntryKeyRef::Value(e.key()),
578				JsonLdObjectEntryValueRef::Value(e),
579			),
580			Self::List(e) => (
581				JsonLdObjectEntryKeyRef::List,
582				JsonLdObjectEntryValueRef::List(e),
583			),
584			Self::Node(e) => {
585				let (k, v) = e.into_key_value();
586				(
587					JsonLdObjectEntryKeyRef::Node(k),
588					JsonLdObjectEntryValueRef::Node(v),
589				)
590			}
591		}
592	}
593
594	pub fn as_key_value(&self) -> (JsonLdObjectEntryKeyRef<'a>, JsonLdObjectEntryValueRef<'a>) {
595		self.into_key_value()
596	}
597}
598
599#[derive(Educe, PartialEq, Eq)]
600#[educe(Clone, Copy)]
601pub enum JsonLdIndexedObjectEntryKeyRef<'a> {
602	Index,
603	Object(JsonLdObjectEntryKeyRef<'a>),
604}
605
606impl<'a> JsonLdIndexedObjectEntryKeyRef<'a> {
607	pub fn into_keyword(self) -> Option<JsonLdKeyword> {
608		match self {
609			Self::Index => Some(JsonLdKeyword::Index),
610			Self::Object(e) => e.into_keyword(),
611		}
612	}
613
614	pub fn as_keyword(&self) -> Option<JsonLdKeyword> {
615		self.into_keyword()
616	}
617
618	pub fn into_str(self) -> &'a str {
619		match self {
620			Self::Index => "@index",
621			Self::Object(e) => e.into_str(),
622		}
623	}
624
625	pub fn as_str(&self) -> &'a str {
626		self.into_str()
627	}
628}
629
630#[derive(Educe)]
631#[educe(Clone, Copy)]
632pub enum JsonLdIndexedObjectEntryValueRef<'a> {
633	Index(&'a str),
634	Object(JsonLdObjectEntryValueRef<'a>),
635}
636
637#[derive(Educe)]
638#[educe(Clone, Copy)]
639pub enum JsonLdIndexedObjectEntryRef<'a> {
640	Index(&'a str),
641	Object(JsonLdObjectEntryRef<'a>),
642}
643
644impl<'a> JsonLdIndexedObjectEntryRef<'a> {
645	pub fn into_key(self) -> JsonLdIndexedObjectEntryKeyRef<'a> {
646		match self {
647			Self::Index(_) => JsonLdIndexedObjectEntryKeyRef::Index,
648			Self::Object(e) => JsonLdIndexedObjectEntryKeyRef::Object(e.key()),
649		}
650	}
651
652	pub fn key(&self) -> JsonLdIndexedObjectEntryKeyRef<'a> {
653		self.into_key()
654	}
655
656	pub fn into_value(self) -> JsonLdIndexedObjectEntryValueRef<'a> {
657		match self {
658			Self::Index(v) => JsonLdIndexedObjectEntryValueRef::Index(v),
659			Self::Object(e) => JsonLdIndexedObjectEntryValueRef::Object(e.value()),
660		}
661	}
662
663	pub fn value(&self) -> JsonLdIndexedObjectEntryValueRef<'a> {
664		self.into_value()
665	}
666
667	pub fn into_key_value(
668		self,
669	) -> (
670		JsonLdIndexedObjectEntryKeyRef<'a>,
671		JsonLdIndexedObjectEntryValueRef<'a>,
672	) {
673		match self {
674			Self::Index(v) => (
675				JsonLdIndexedObjectEntryKeyRef::Index,
676				JsonLdIndexedObjectEntryValueRef::Index(v),
677			),
678			Self::Object(e) => {
679				let (k, v) = e.into_key_value();
680				(
681					JsonLdIndexedObjectEntryKeyRef::Object(k),
682					JsonLdIndexedObjectEntryValueRef::Object(v),
683				)
684			}
685		}
686	}
687
688	pub fn as_key_value(
689		&self,
690	) -> (
691		JsonLdIndexedObjectEntryKeyRef<'a>,
692		JsonLdIndexedObjectEntryValueRef<'a>,
693	) {
694		self.into_key_value()
695	}
696}
697
698impl AnyJsonLdObject for JsonLdObject {
699	#[inline(always)]
700	fn as_ref(&self) -> JsonLdObjectRef<'_> {
701		match self {
702			JsonLdObject::Value(value) => JsonLdObjectRef::Value(value),
703			JsonLdObject::Node(node) => JsonLdObjectRef::Node(node),
704			JsonLdObject::List(list) => JsonLdObjectRef::List(list),
705		}
706	}
707}
708
709impl From<JsonLdValue> for JsonLdObject {
710	#[inline(always)]
711	fn from(value: JsonLdValue) -> Self {
712		Self::Value(value)
713	}
714}
715
716impl From<JsonLdNode> for JsonLdObject {
717	#[inline(always)]
718	fn from(node: JsonLdNode) -> Self {
719		Self::node(node)
720	}
721}
722
723/// Iterator through the types of an object.
724pub enum JsonLdObjectTypes<'a> {
725	Value(Option<value::JsonLdValueTypeRef<'a>>),
726	Node(Option<btree_indexmap::multi_set::Iter<'a, JsonLdLenient<Id>>>),
727	List,
728}
729
730impl<'a> Iterator for JsonLdObjectTypes<'a> {
731	type Item = JsonLdObjectTypeRef<'a>;
732
733	fn next(&mut self) -> Option<Self::Item> {
734		match self {
735			Self::Value(ty) => ty.take().map(JsonLdObjectTypeRef::from_value_type),
736			Self::Node(tys) => tys.as_mut()?.next().map(JsonLdObjectTypeRef::from_id),
737			Self::List => None,
738		}
739	}
740}
741
742/// Iterator through indexed objects.
743pub struct JsonLdObjects<'a>(Option<std::slice::Iter<'a, JsonLdIndexedObject>>);
744
745impl<'a> JsonLdObjects<'a> {
746	#[inline(always)]
747	pub(crate) fn new(inner: Option<std::slice::Iter<'a, JsonLdIndexedObject>>) -> Self {
748		Self(inner)
749	}
750}
751
752impl<'a> Iterator for JsonLdObjects<'a> {
753	type Item = &'a JsonLdIndexedObject;
754
755	#[inline(always)]
756	fn next(&mut self) -> Option<&'a JsonLdIndexedObject> {
757		match &mut self.0 {
758			None => None,
759			Some(it) => it.next(),
760		}
761	}
762}