| Crates.io | simple_endian_derive |
| lib.rs | simple_endian_derive |
| version | 0.4.10 |
| created_at | 2026-01-02 23:32:45.040441+00 |
| updated_at | 2026-01-06 09:38:04.331699+00 |
| description | Proc-macros for the simple_endian crate. |
| homepage | |
| repository | https://github.com/rexlunae/simple-endian-rs |
| max_upload_size | |
| id | 2019341 |
| size | 65,464 |
simple_endian_deriveThis crate provides the proc-macro implementation behind #[derive(Endianize)] for the simple_endian crate.
You generally should not depend on this crate directly.
Enable the derive feature on simple_endian instead, which re-exports the derive macro.
In your Cargo.toml:
[dependencies]
simple_endian = { version = "0.4", features = ["derive"] }
Then:
use simple_endian::Endianize;
#[derive(Endianize)]
#[endian(le)]
#[repr(C)]
struct Header {
magic: u32,
version: u16,
}
// Generated by the macro:
// - `HeaderWire` (wire-format representation)
For a type named T, the macro generates a TWire companion type whose fields are endian-aware and whose layout is intended for IO.
The recommended workflow in the simple_endian ecosystem is native-first:
TWire (or using read_native / write_native when io-std is enabled).#[endian(le)] / #[endian(be)] (required)#[wire_repr(...)] – controls the generated wire type representation (e.g. #[repr(C)], #[repr(C, packed)])#[wire_derive(...)] – derives to apply to the generated *Wire type#[wire_default] / #[wire_default(...)] – controls Default generation for wire types#[text(...)] – fixed-size text fields (feature-gated by simple_endian text features)#[tuple_text] – support for tuple enum variants in text contextsEnum wire types are represented as tag + union payload to match on-wire layout.
Unions cannot derive many common traits (notably Debug, PartialEq, Eq, Hash, ...).
If you apply #[wire_derive(...)] to an enum, keep those restrictions in mind.
In most cases you should keep derives on the native enum (where they make semantic sense), and convert at IO boundaries.
This crate is maintained in the simple-endian-rs repository alongside the main library crate.