| Crates.io | xdr_brk_enum |
| lib.rs | xdr_brk_enum |
| version | 0.1.2 |
| created_at | 2025-08-20 05:07:25.198331+00 |
| updated_at | 2025-08-24 05:54:36.154729+00 |
| description | A proc-macro crate that provides a derive macro for serde::Serialize and serde::Deserialize on Rust enum types, to support XDR (External Data Representation) serialization and deserialization. |
| homepage | |
| repository | https://github.com/algebnaly/xdr_brk_enum |
| max_upload_size | |
| id | 1802880 |
| size | 17,853 |
This is a proc-macro crate that provides a derive macro for serde::Serialize and serde::Deserialize on Rust enum types, to support XDR (External Data Representation) serialization and deserialization.
Add this crate to your Cargo.toml:
[dependencies]
serde = { version = "1.0" }
xdr_brk_enum = "0.1"
xdr_brk = "0.1"
and in your Rust code:
use xdr_brk_enum::XDREnumSerialize;
const fn foo() -> u32 {
42
}
#[repr(u32)]
#[derive(XDREnumSerialize)]
enum MyEnum {
Variant1 = foo(),
Variant2(String) = 0,
Variant3 { field1: i32, field2: f64 } = 100,
}
fn main(){
let my_enum = MyEnum::Variant1;
let serialized = xdr_brk::to_bytes(&my_enum).unwrap();
println!("Serialized: {:?}", serialized);
}