onionpack 1.0.0

Unpack your structs into DTOs, Entities and Schemas.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 19.05 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 301.18 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • h4-h/onionpack
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • h4-h

OnionPack

Crate that will unpack your struct for layered architecture.

Usage

// 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.

Contributing

Wanna contribute?

License: MIT.