Macro serai_coordinator::db::create_db
source · macro_rules! create_db { ($db_name: ident { $($field_name: ident: ($($arg: ident: $arg_type: ty),*) -> $field_type: ty$(,)?)* }) => { ... }; }
Expand description
Creates a series of structs which provide namespacing for keys
§Description
Creates a unit struct and a default implementation for the key
, get
, and set
. The macro
uses a syntax similar to defining a function. Parameters are concatenated to produce a key,
they must be scale
encodable. The return type is used to auto encode and decode the database
value bytes using borsh
.
§Arguments
db_name
- A database namefield_name
- An item nameargs
- Comma separated list of key argumentsfield_type
- The return type
§Example
ⓘ
create_db!(
TributariesDb {
AttemptsDb: (key_bytes: &[u8], attempt_id: u32) -> u64,
ExpiredDb: (genesis: [u8; 32]) -> Vec<u8>
}
)