Skip to main content

kind

Macro kind 

Source
macro_rules! kind {
    () => { ... };
    ($name:ident = $kind:literal $(: $id:ty)? $(, $($rest:tt)*)?) => { ... };
    ($name:ident = $kind:path $(: $id:ty)? $(, $($rest:tt)*)?) => { ... };
    ($name:ident = $kind:block $(: $id:ty)? $(, $($rest:tt)*)?) => { ... };
}
Expand description

Declares kinds, each with its id type (String when none is said). A kind’s name is a string literal or a path to a &'static str constant (Mesh = ids::MESH, for names a format keeps in one place), or a { block } of one; either way it is checked when the kind compiles.

substrate_data::kind!(User = "user": u64, Doc = "doc");

mod ids {
    pub const FILE: &str = "file";
}
substrate_data::kind!(File = ids::FILE: u64, User = "user");
assert_eq!(<File as substrate_data::Kind>::NAME, "file");