Skip to main content

Crate ic_db_macros

Crate ic_db_macros 

Source
Expand description

Small attribute authoring boundary for the first persistent-record slice. Generates typed records/codecs and metadata, never endpoints or executors. All declarations use empty, nongeneric struct bodies without where clauses; unsupported Rust constraints are rejected rather than discarded during expansion.

Attribute Macros§

entity
Author a typed record with named fields, a supplied scalar key and indexes.
enum_
Declare a named enum using an empty struct and variant(name = "...") attributes. Supports 1–64 unit or typed payload variants. Canonical name order determines stored ordinals; source declaration order does not. Use item(indirect, is = “Self”) for boxed recursion, with a finite base alternative. All-unit enums also convert by reference into ic_db::IndexValue, using the same canonical order. Any payload variant excludes the whole enum from indexes.
list
Declare a reusable ordered list with an item type and a shared maximum length.
map
Declare a named BTreeMap wrapper using key(...), value(...) and max_items = N (0..256). Keys are primitives, scalar newtypes or unit enums. Values use the ordinary optional/list/named field rules; stored duplicate keys refuse.
newtype
Declare a distinct Rust and schema type around one primitive, including its bounds.
record
Declare a named stored record using attribute-owned fields and an empty struct.
set
Declare a bounded ordered set with item(...) and max_items = N (0..256). Elements can be primitives, scalar newtypes or unit enums. The generated wrapper contains a BTreeSet<T>. Decoding requires strictly increasing keys.