icydb_schema/node/
arg.rs

1use crate::{
2    node::{ValidateNode, VisitableNode},
3    visit::Visitor,
4};
5use derive_more::{Deref, Display};
6use serde::Serialize;
7
8///
9/// Arg
10///
11
12#[derive(Clone, Debug, Display, Serialize)]
13pub enum Arg {
14    Bool(bool),
15    Char(char),
16    Number(ArgNumber),
17    ConstPath(&'static str),
18    FuncPath(&'static str),
19    String(&'static str),
20}
21
22impl ValidateNode for Arg {}
23
24impl VisitableNode for Arg {
25    fn route_key(&self) -> String {
26        format!("arg ({self})")
27    }
28
29    fn drive<V: Visitor>(&self, v: &mut V) {
30        if let Self::Number(node) = self {
31            node.accept(v);
32        }
33    }
34}
35
36///
37/// Args
38///
39
40#[derive(Clone, Debug, Deref, Serialize)]
41pub struct Args(pub &'static [Arg]);
42
43impl ValidateNode for Args {}
44
45///
46/// ArgNumber
47///
48
49#[derive(Clone, Debug, Display, Serialize)]
50pub enum ArgNumber {
51    Float32(f32),
52    Float64(f64),
53    Int8(i8),
54    Int16(i16),
55    Int32(i32),
56    Int64(i64),
57    Int128(i128),
58    Nat8(u8),
59    Nat16(u16),
60    Nat32(u32),
61    Nat64(u64),
62    Nat128(u128),
63}
64
65impl ValidateNode for ArgNumber {}
66
67impl VisitableNode for ArgNumber {}