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
use crate::prelude::*;
///
/// Map
///
/// Schema node describing a map collection with key/value descriptors and one
/// canonical runtime type.
///
#[derive(Clone, Debug, Serialize)]
pub struct Map {
def: Def,
key: Item,
value: Value,
ty: Type,
}
impl Map {
/// Creates a map node from its canonical schema parts.
#[must_use]
pub const fn new(def: Def, key: Item, value: Value, ty: Type) -> Self {
Self {
def,
key,
value,
ty,
}
}
/// Returns the definition metadata for this map node.
#[must_use]
pub const fn def(&self) -> &Def {
&self.def
}
/// Returns the key descriptor.
#[must_use]
pub const fn key(&self) -> &Item {
&self.key
}
/// Returns the value descriptor.
#[must_use]
pub const fn value(&self) -> &Value {
&self.value
}
/// Returns the canonical runtime type descriptor.
#[must_use]
pub const fn ty(&self) -> &Type {
&self.ty
}
}
impl MacroNode for Map {
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
impl TypeNode for Map {
fn ty(&self) -> &Type {
self.ty()
}
}
impl ValidateNode for Map {}
impl VisitableNode for Map {
fn route_key(&self) -> String {
self.def().path()
}
fn drive<V: Visitor>(&self, v: &mut V) {
self.def().accept(v);
self.key().accept(v);
self.value().accept(v);
self.ty().accept(v);
}
}