use crate::prelude::*;
#[derive(Clone, Debug, Serialize)]
pub struct Set {
def: Def,
name: &'static str,
item: Item,
ty: Type,
}
impl Set {
#[must_use]
pub const fn new(def: Def, name: &'static str, item: Item, ty: Type) -> Self {
Self {
def,
name,
item,
ty,
}
}
#[must_use]
pub const fn def(&self) -> &Def {
&self.def
}
#[must_use]
pub const fn name(&self) -> &'static str {
self.name
}
#[must_use]
pub const fn item(&self) -> &Item {
&self.item
}
#[must_use]
pub const fn ty(&self) -> &Type {
&self.ty
}
}
impl MacroNode for Set {
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
impl ValidateNode for Set {
fn validate(&self) -> Result<(), ErrorTree> {
let mut errs = ErrorTree::new();
validate_source_name(
&mut errs,
"set type",
self.name(),
icydb_schema::TypeSourceKey::try_new,
);
errs.result()
}
}
impl VisitableNode for Set {
fn route_key(&self) -> String {
self.def().path()
}
fn drive<V: Visitor>(&self, v: &mut V) {
self.def().accept(v);
self.item().accept(v);
self.ty().accept(v);
}
}