redb_model
Redb Model
A derive macro for generating [redb] table definitions and DTO object
conversion methods/implementations.
Functionality
All functionality is implemented by the [Model] trait within. Decorating
a struct with #[derive(Model)] will define a redb::TableDefinition as
an associated constant for the type, with the specified fields as key/value
types, or tuples of types.
Specifying keys and values
Key(s) and value(s) are specified by decorating table fields with
#[entry(position(...))], passing either key or value to the inner field.
let user_key = ;
let user_value = ;
let user = from_values;
Specifying a table name
Table names default to the (case-sensitive) struct name. This can be overridden by decorating
the struct with #[model(name = "...")] attribute.
assert_eq!;
Type conversion
The generated implementation of the [Model] trait provides methods for
instantiating, borrowing and taking the key/value pairs from the model DTO.
See the methods of the [Model] trait for available methods. By default,
#[derive(Model)] will only generate an implementation of the Model trait.
Decorating the struct with #[model(impl_from)] will implement From<T>,
mapping T to the from_values and from_guards methods.
let user_key = ;
let user_value = ;
let user: User = .into;
Variable Ordering
All composite key/value variables are combined as a tuple in the order they are defined.
License: MIT OR Apache-2.0