impl_data_entity

Macro impl_data_entity 

Source
macro_rules! impl_data_entity {
    (
        $type:ident,
        $type_name:expr,
        [ $( $indexed_field:expr ),* $(,)? ],
        {
            $( $specific_field:ident : $specific_type:ty ),* $(,)?
        }
    ) => { ... };
}
Expand description

Complete macro to create a Data entity with automatic trait implementations

§Example

use this::prelude::*;

impl_data_entity!(
    User,
    "user",
    ["name", "email"],
    {
        email: String,
        password_hash: String,
        roles: Vec<String>,
    }
);

// Usage
let user = User::new(
    "John Doe".to_string(),
    "active".to_string(),
    "john@example.com".to_string(),
    "$argon2$...".to_string(),
    vec!["admin".to_string()],
);