jsonld_core/document/
flattened.rs1use rdfx::{LocalGenerator, vocabulary::VocabularyMut};
2
3use crate::{HashMap, IdentifyAll, IndexedNode, Relabel, ValidId};
4use std::{collections::HashSet, hash::Hash};
5
6pub type FlattenedDocument<T, B> = Vec<IndexedNode<T, B>>;
10
11impl<T, B> IdentifyAll<T, B> for FlattenedDocument<T, B> {
12 #[inline(always)]
13 fn identify_all_with<V: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>(
14 &mut self,
15 vocabulary: &mut V,
16 generator: &mut G,
17 ) -> Result<(), crate::id::GeneratedIdError>
18 where
19 T: Eq + Hash,
20 B: Eq + Hash,
21 {
22 for node in self {
23 node.identify_all_with(vocabulary, generator)?;
24 }
25 Ok(())
26 }
27}
28
29impl<T, B> Relabel<T, B> for FlattenedDocument<T, B> {
30 fn relabel_with<N: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>(
31 &mut self,
32 vocabulary: &mut N,
33 generator: &mut G,
34 relabeling: &mut HashMap<B, ValidId<T, B>>,
35 ) -> Result<(), crate::id::GeneratedIdError>
36 where
37 T: Clone + Eq + Hash,
38 B: Clone + Eq + Hash,
39 {
40 for node in self {
41 node.relabel_with(vocabulary, generator, relabeling)?;
42 }
43 Ok(())
44 }
45}
46
47pub type UnorderedFlattenedDocument<T, B> = HashSet<IndexedNode<T, B>>;