json_ld_core/deserialization/object/
mod.rs1mod list;
2mod node;
3mod value;
4
5use linked_data::{
6 LinkedData, LinkedDataGraph, LinkedDataPredicateObjects, LinkedDataResource, LinkedDataSubject,
7};
8use rdf_types::{vocabulary::IriVocabularyMut, Interpretation, Vocabulary};
9
10use crate::Object;
11
12impl<T, B, V: Vocabulary<Iri = T>, I: Interpretation> LinkedDataResource<I, V> for Object<T, B>
13where
14 T: LinkedDataResource<I, V>,
15 B: LinkedDataResource<I, V>,
16{
17 fn interpretation(
18 &self,
19 vocabulary: &mut V,
20 interpretation: &mut I,
21 ) -> linked_data::ResourceInterpretation<I, V> {
22 match self {
23 Self::Node(node) => node.interpretation(vocabulary, interpretation),
24 Self::List(list) => list.interpretation(vocabulary, interpretation),
25 Self::Value(value) => value.interpretation(vocabulary, interpretation),
26 }
27 }
28}
29
30impl<T, B, V: Vocabulary<Iri = T>, I: Interpretation> LinkedDataSubject<I, V> for Object<T, B>
31where
32 T: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
33 B: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
34 V: IriVocabularyMut,
35{
36 fn visit_subject<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
37 where
38 S: linked_data::SubjectVisitor<I, V>,
39 {
40 match self {
41 Self::Node(node) => node.visit_subject(visitor),
42 Self::List(list) => list.visit_subject(visitor),
43 Self::Value(value) => value.visit_subject(visitor),
44 }
45 }
46}
47
48impl<T, B, V: Vocabulary<Iri = T>, I: Interpretation> LinkedDataPredicateObjects<I, V>
49 for Object<T, B>
50where
51 T: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
52 B: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
53 V: IriVocabularyMut,
54{
55 fn visit_objects<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
56 where
57 S: linked_data::PredicateObjectsVisitor<I, V>,
58 {
59 match self {
60 Self::Node(node) => node.visit_objects(visitor),
61 Self::List(list) => list.visit_objects(visitor),
62 Self::Value(value) => value.visit_objects(visitor),
63 }
64 }
65}
66
67impl<T, B, V: Vocabulary<Iri = T>, I: Interpretation> LinkedDataGraph<I, V> for Object<T, B>
68where
69 T: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
70 B: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
71 V: IriVocabularyMut,
72{
73 fn visit_graph<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
74 where
75 S: linked_data::GraphVisitor<I, V>,
76 {
77 match self {
78 Self::Node(node) => node.visit_graph(visitor),
79 Self::List(list) => list.visit_graph(visitor),
80 Self::Value(value) => value.visit_graph(visitor),
81 }
82 }
83}
84
85impl<T, B, V: Vocabulary<Iri = T>, I: Interpretation> LinkedData<I, V> for Object<T, B>
86where
87 T: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
88 B: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
89 V: IriVocabularyMut,
90{
91 fn visit<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
92 where
93 S: linked_data::Visitor<I, V>,
94 {
95 match self {
96 Self::Node(node) => node.visit(visitor),
97 Self::List(list) => list.visit(visitor),
98 Self::Value(value) => value.visit(visitor),
99 }
100 }
101}