Skip to main content

icydb_schema/node/
def.rs

1use crate::prelude::*;
2
3///
4/// Def
5///
6
7#[derive(CandidType, Clone, Debug, Serialize)]
8pub struct Def {
9    module_path: &'static str,
10    ident: &'static str,
11}
12
13impl Def {
14    /// Build one schema-definition identity pair.
15    #[must_use]
16    pub const fn new(module_path: &'static str, ident: &'static str) -> Self {
17        Self { module_path, ident }
18    }
19
20    /// Borrow definition module path.
21    #[must_use]
22    pub const fn module_path(&self) -> &'static str {
23        self.module_path
24    }
25
26    /// Borrow definition identifier.
27    #[must_use]
28    pub const fn ident(&self) -> &'static str {
29        self.ident
30    }
31
32    // path
33    // the path to the actual Type
34    // ie. design::game::Rarity
35    #[must_use]
36    pub fn path(&self) -> String {
37        format!("{}::{}", self.module_path(), self.ident())
38    }
39}
40
41impl ValidateNode for Def {}
42
43impl VisitableNode for Def {}