Expand description
#[derive(Schema)] — see substrate_data::Schema.
-
A struct with named fields is an object. Field attributes:
#[data(rename = "name")],#[data(default)]/#[data(default = "path::to_fn")],#[data(skip)](never read or written;Default).Optionfields may be left out. -
A struct with one unnamed field is that field’s format.
-
An enum of unit variants is a string: the variant’s name in
snake_case, or#[data(rename = "...")]. -
#[data(tag = "type")]on an enum: an object whosetypenames the variant; a variant is a unit, has named fields, or wraps one value — a struct’s fields sit next to the tag, anything else undervalue(substrate_data::schema::WRAPPED). -
#[data(view)]on a struct:NameView<'a>too, the struct read out of a frame without copying (substrate_data::frame::View).
Every type also packs itself into frames (pack / unpack: fields by
position, unit enums by index) and writes the binary form straight
(encode / decode).
Doc comments become the shape’s docs (an editor’s hover text and the docs’ field tables).
Derive Macros§
- Schema
#[derive(Schema)]: see the crate’s docs.