Crates.io | onionpack |
lib.rs | onionpack |
version | 1.0.0 |
source | src |
created_at | 2024-10-02 11:24:35.590242 |
updated_at | 2024-10-02 11:24:35.590242 |
description | Unpack your structs into DTOs, Entities and Schemas. |
homepage | |
repository | https://github.com/h4-h/onionpack |
max_upload_size | |
id | 1393948 |
size | 19,549 |
Crate that will unpack your struct for layered architecture.
// This:
#[derive(onionpack::OnionPack)]
#[onion_derive(
all(Debug), // Describes what derives will have all structs
dto(PartialEq, Eq) // Describes what derives will have `UserDto`
// Can be appended wtith `scheme` and `entity` if you need derives for them.
)]
struct User {
name: String, // No `onion_dist` mean that this field will appear in all structs.
#[onion_dist(dto, entity)] // Describes where field will appear: `scheme` and/or `dto` and/or `entity`.
password_hash: String,
#[onion_dist(none)] // Doesn't appear in child structs.
hidden_value: i32,
}
// Generates this:
#[derive(Debug)]
pub struct UserScheme {
name: String,
}
#[derive(Debug, PartialEq, Eq)]
pub struct UserDto {
name: String,
password_hash: String,
}
#[derive(Debug)]
pub struct UserEntity {
name: String,
password_hash: String,
}
See UNPACK_EXAMPLE.md
or examples
for more examples.
Wanna contribute?
TODO
-list in src/lib.rs
.README.md
, UNPACK_EXAMPLE.md
, etc.License: MIT.