1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use iref::{Iri, IriBuf};

use crate::{
	BlankId, BlankIdBuf, BlankIdInterpretation, BlankIdInterpretationMut, Id, Interpretation,
	IriInterpretation, IriInterpretationMut, Literal, LiteralInterpretation,
	LiteralInterpretationMut, ReverseLiteralInterpretation, Term,
};

use super::{ReverseBlankIdInterpretation, ReverseIriInterpretation};

impl Interpretation for () {
	type Resource = Term;
}

impl IriInterpretation<IriBuf> for () {
	fn iri_interpretation(&self, iri: &IriBuf) -> Option<Self::Resource> {
		Some(Term::Id(Id::Iri(iri.clone())))
	}
}

impl IriInterpretationMut<IriBuf> for () {
	fn interpret_iri(&mut self, iri: IriBuf) -> Self::Resource {
		Term::Id(Id::Iri(iri))
	}
}

impl IriInterpretation<Iri> for () {
	fn iri_interpretation(&self, iri: &Iri) -> Option<Self::Resource> {
		Some(Term::Id(Id::Iri(iri.to_owned())))
	}
}

impl ReverseIriInterpretation for () {
	type Iri = IriBuf;

	type Iris<'a> = std::option::IntoIter<&'a IriBuf>;

	fn iris_of<'a>(&'a self, id: &'a Self::Resource) -> Self::Iris<'a> {
		match id {
			Term::Id(Id::Iri(iri)) => Some(iri).into_iter(),
			_ => None.into_iter(),
		}
	}
}

impl BlankIdInterpretation<BlankIdBuf> for () {
	fn blank_id_interpretation(&self, blank_id: &BlankIdBuf) -> Option<Self::Resource> {
		Some(Term::Id(Id::Blank(blank_id.to_owned())))
	}
}

impl BlankIdInterpretationMut<BlankIdBuf> for () {
	fn interpret_blank_id(&mut self, blank_id: BlankIdBuf) -> Self::Resource {
		Term::Id(Id::Blank(blank_id))
	}
}

impl BlankIdInterpretation<BlankId> for () {
	fn blank_id_interpretation(&self, blank_id: &BlankId) -> Option<Self::Resource> {
		Some(Term::Id(Id::Blank(blank_id.to_owned())))
	}
}

impl ReverseBlankIdInterpretation for () {
	type BlankId = BlankIdBuf;

	type BlankIds<'a> = std::option::IntoIter<&'a BlankIdBuf>;

	fn blank_ids_of<'a>(&'a self, id: &'a Self::Resource) -> Self::BlankIds<'a> {
		match id {
			Term::Id(Id::Blank(b)) => Some(b).into_iter(),
			_ => None.into_iter(),
		}
	}
}

impl LiteralInterpretation<Literal> for () {
	fn literal_interpretation(&self, literal: &Literal) -> Option<Self::Resource> {
		Some(Term::Literal(literal.clone()))
	}
}

impl LiteralInterpretationMut<Literal> for () {
	fn interpret_literal(&mut self, literal: Literal) -> Self::Resource {
		Term::Literal(literal)
	}
}

impl ReverseLiteralInterpretation for () {
	type Literal = Literal;

	type Literals<'a> = std::option::IntoIter<&'a Literal>;

	fn literals_of<'a>(&'a self, id: &'a Self::Resource) -> Self::Literals<'a> {
		match id {
			Term::Literal(l) => Some(l).into_iter(),
			_ => None.into_iter(),
		}
	}
}