rdf_types/interpretation/impl/
none.rs

1use iref::{Iri, IriBuf};
2
3use crate::{
4	interpretation::{
5		BlankIdInterpretation, BlankIdInterpretationMut, IriInterpretation, IriInterpretationMut,
6		LiteralInterpretation, LiteralInterpretationMut, ReverseBlankIdInterpretation,
7		ReverseIriInterpretation, ReverseLiteralInterpretation,
8	},
9	BlankId, BlankIdBuf, Id, Interpretation, Literal, Term,
10};
11
12impl Interpretation for () {
13	type Resource = Term;
14}
15
16impl IriInterpretation<IriBuf> for () {
17	fn iri_interpretation(&self, iri: &IriBuf) -> Option<Self::Resource> {
18		Some(Term::Id(Id::Iri(iri.clone())))
19	}
20}
21
22impl IriInterpretationMut<IriBuf> for () {
23	fn interpret_iri(&mut self, iri: IriBuf) -> Self::Resource {
24		Term::Id(Id::Iri(iri))
25	}
26}
27
28impl IriInterpretation<Iri> for () {
29	fn iri_interpretation(&self, iri: &Iri) -> Option<Self::Resource> {
30		Some(Term::Id(Id::Iri(iri.to_owned())))
31	}
32}
33
34impl ReverseIriInterpretation for () {
35	type Iri = IriBuf;
36
37	type Iris<'a> = std::option::IntoIter<&'a IriBuf>;
38
39	fn iris_of<'a>(&'a self, id: &'a Self::Resource) -> Self::Iris<'a> {
40		match id {
41			Term::Id(Id::Iri(iri)) => Some(iri).into_iter(),
42			_ => None.into_iter(),
43		}
44	}
45}
46
47impl BlankIdInterpretation<BlankIdBuf> for () {
48	fn blank_id_interpretation(&self, blank_id: &BlankIdBuf) -> Option<Self::Resource> {
49		Some(Term::Id(Id::Blank(blank_id.to_owned())))
50	}
51}
52
53impl BlankIdInterpretationMut<BlankIdBuf> for () {
54	fn interpret_blank_id(&mut self, blank_id: BlankIdBuf) -> Self::Resource {
55		Term::Id(Id::Blank(blank_id))
56	}
57}
58
59impl BlankIdInterpretation<BlankId> for () {
60	fn blank_id_interpretation(&self, blank_id: &BlankId) -> Option<Self::Resource> {
61		Some(Term::Id(Id::Blank(blank_id.to_owned())))
62	}
63}
64
65impl ReverseBlankIdInterpretation for () {
66	type BlankId = BlankIdBuf;
67
68	type BlankIds<'a> = std::option::IntoIter<&'a BlankIdBuf>;
69
70	fn blank_ids_of<'a>(&'a self, id: &'a Self::Resource) -> Self::BlankIds<'a> {
71		match id {
72			Term::Id(Id::Blank(b)) => Some(b).into_iter(),
73			_ => None.into_iter(),
74		}
75	}
76}
77
78impl LiteralInterpretation<Literal> for () {
79	fn literal_interpretation(&self, literal: &Literal) -> Option<Self::Resource> {
80		Some(Term::Literal(literal.clone()))
81	}
82}
83
84impl LiteralInterpretationMut<Literal> for () {
85	fn interpret_literal(&mut self, literal: Literal) -> Self::Resource {
86		Term::Literal(literal)
87	}
88}
89
90impl ReverseLiteralInterpretation for () {
91	type Literal = Literal;
92
93	type Literals<'a> = std::option::IntoIter<&'a Literal>;
94
95	fn literals_of<'a>(&'a self, id: &'a Self::Resource) -> Self::Literals<'a> {
96		match id {
97			Term::Literal(l) => Some(l).into_iter(),
98			_ => None.into_iter(),
99		}
100	}
101}