Skip to main content

icydb_schema/node/
arg.rs

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