Skip to main content

icydb_schema/node/
record.rs

1use crate::prelude::*;
2
3///
4/// Record
5///
6
7#[derive(Clone, Debug, Serialize)]
8pub struct Record {
9    def: Def,
10    fields: FieldList,
11    ty: Type,
12}
13
14impl Record {
15    /// Creates a record node from its canonical schema parts.
16    #[must_use]
17    pub const fn new(def: Def, fields: FieldList, ty: Type) -> Self {
18        Self { def, fields, ty }
19    }
20
21    /// Returns the definition metadata for this record node.
22    #[must_use]
23    pub const fn def(&self) -> &Def {
24        &self.def
25    }
26
27    /// Returns the record field list.
28    #[must_use]
29    pub const fn fields(&self) -> &FieldList {
30        &self.fields
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 Record {
41    fn as_any(&self) -> &dyn std::any::Any {
42        self
43    }
44}
45
46impl ValidateNode for Record {}
47
48impl VisitableNode for Record {
49    fn route_key(&self) -> String {
50        self.def().path()
51    }
52
53    fn drive<V: Visitor>(&self, v: &mut V) {
54        self.def().accept(v);
55        self.fields().accept(v);
56        self.ty().accept(v);
57    }
58}