Skip to main content

vm/builtins/
metadata.rs

1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2pub enum CallableParamType {
3    Any,
4    Null,
5    Int,
6    Float,
7    Bool,
8    String,
9    Bytes,
10    Array,
11    Map,
12    Number,
13}
14
15impl CallableParamType {
16    pub const fn label(self) -> &'static str {
17        match self {
18            Self::Any => "any",
19            Self::Null => "null",
20            Self::Int => "int",
21            Self::Float => "float",
22            Self::Bool => "bool",
23            Self::String => "string",
24            Self::Bytes => "bytes",
25            Self::Array => "array",
26            Self::Map => "map",
27            Self::Number => "number",
28        }
29    }
30}
31
32#[derive(Clone, Copy, Debug, PartialEq, Eq)]
33pub struct CallableParam {
34    pub name: &'static str,
35    pub ty: CallableParamType,
36    pub optional: bool,
37}
38
39#[derive(Clone, Copy, Debug, PartialEq, Eq)]
40pub struct CallableSignature {
41    pub params: &'static [CallableParam],
42    pub return_type: &'static str,
43}
44
45#[derive(Clone, Copy, Debug, PartialEq, Eq)]
46pub struct CallableDef {
47    pub name: &'static str,
48    pub docs: &'static str,
49    pub signature: CallableSignature,
50}
51
52#[allow(dead_code)]
53pub mod marker {
54    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
55    pub struct Any;
56
57    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
58    pub struct Array;
59
60    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
61    pub struct Bytes;
62
63    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
64    pub struct Map;
65
66    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
67    pub struct Number;
68
69    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
70    pub struct Unknown;
71}