Skip to main content

Key

Derive Macro Key 

Source
#[derive(Key)]
{
    // Attributes available to this derive:
    #[redb]
}
Expand description

Derives redb::Key for a struct whose fields all implement Key.

The generated implementation refers to the redb crate as ::redb. When it should be generated for a crate under another name – a renamed dependency (my_redb = { package = "redb" }), or one of several versions of redb – name that crate with #[redb(crate = "my_redb")]. For a struct with fields, the generated implementation uses TypeName API that redb makes public from 3.0 on; a unit struct works with older versions as well. For a struct with exactly one field, the derived Value implementation forwards the field’s Value::NICHE, so such a struct needs a version that has that constant. The tagging of user-defined field types in the composed type name follows the named version’s classification: redb 4.1 and older classify composites (Option, Vec, tuples, arrays) of user-defined types as built-in, so such composite fields render untagged there, and their names collide exactly where that version’s own type names do.