Skip to main content

icydb_schema/node/
set.rs

1use crate::prelude::*;
2
3///
4/// Set
5///
6
7#[derive(Clone, Debug, Serialize)]
8pub struct Set {
9    def: Def,
10    item: Item,
11    ty: Type,
12}
13
14impl Set {
15    /// Creates a set node from its canonical schema parts.
16    #[must_use]
17    pub const fn new(def: Def, item: Item, ty: Type) -> Self {
18        Self { def, item, ty }
19    }
20
21    /// Returns the definition metadata for this set node.
22    #[must_use]
23    pub const fn def(&self) -> &Def {
24        &self.def
25    }
26
27    /// Returns the set item descriptor.
28    #[must_use]
29    pub const fn item(&self) -> &Item {
30        &self.item
31    }
32
33    /// Returns the canonical runtime type descriptor.
34    #[must_use]
35    pub const fn ty(&self) -> &Type {
36        &self.ty
37    }
38}
39
40impl MacroNode for Set {
41    fn as_any(&self) -> &dyn std::any::Any {
42        self
43    }
44}
45
46impl TypeNode for Set {
47    fn ty(&self) -> &Type {
48        self.ty()
49    }
50}
51
52impl ValidateNode for Set {}
53
54impl VisitableNode for Set {
55    fn route_key(&self) -> String {
56        self.def().path()
57    }
58
59    fn drive<V: Visitor>(&self, v: &mut V) {
60        self.def().accept(v);
61        self.item().accept(v);
62        self.ty().accept(v);
63    }
64}