| Crates.io | oxicode_derive |
| lib.rs | oxicode_derive |
| version | 0.1.0 |
| created_at | 2025-12-28 16:43:18.821829+00 |
| updated_at | 2025-12-28 16:43:18.821829+00 |
| description | Derive macros for oxicode |
| homepage | |
| repository | https://github.com/cool-japan/oxicode |
| max_upload_size | |
| id | 2009125 |
| size | 16,992 |
Procedural macros for deriving Encode and Decode traits for the OxiCode binary serialization library.
This crate provides derive macros that automatically implement the Encode and Decode traits for your custom types. It is part of the OxiCode ecosystem and is typically used through the main oxicode crate with the derive feature enabled.
Add oxicode to your Cargo.toml with the derive feature:
[dependencies]
oxicode = { version = "0.1", features = ["derive"] }
Then use the derive macros on your types:
use oxicode::{Encode, Decode};
#[derive(Encode, Decode)]
struct Point {
x: f32,
y: f32,
}
#[derive(Encode, Decode)]
enum Message {
Quit,
Move { x: i32, y: i32 },
Write(String),
}
The derive macros support:
use oxicode::{encode, decode, Encode, Decode};
#[derive(Debug, PartialEq, Encode, Decode)]
struct User<'a> {
id: u64,
name: &'a str,
active: bool,
}
#[derive(Debug, PartialEq, Encode, Decode)]
enum Status {
Active,
Inactive,
Pending { reason: String },
}
fn main() -> Result<(), oxicode::Error> {
let user = User {
id: 42,
name: "Alice",
active: true,
};
let bytes = encode(&user)?;
let decoded: User = decode(&bytes)?;
assert_eq!(user, decoded);
Ok(())
}
Result typesEncode and Decode manuallyFor detailed documentation, see the OxiCode crate documentation.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please see the main repository for contribution guidelines.