oxicode_derive
Procedural macros for deriving Encode and Decode traits for the OxiCode binary serialization library.
Overview
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.
Usage
Add oxicode to your Cargo.toml with the derive feature:
[]
= { = "0.2", = ["derive"] }
Then use the derive macros on your types:
use ;
Supported Types
The derive macros support:
- Structs with named fields, unnamed fields (tuple structs), or unit structs
- Enums with any combination of named, unnamed, and unit variants
- Generics with full lifetime and type parameter support
- Where clauses and bounds
Example
use ;
Features
- Zero-cost abstractions: Generated code is as efficient as hand-written implementations
- Generic support: Full support for generic types with automatic trait bounds
- Lifetime support: Works seamlessly with borrowed data
- Error handling: Proper error propagation with
Resulttypes
Limitations
- Unions: Derive macros cannot be used on unions due to safety concerns
- Manual implementations: For complex scenarios, you may need to implement
EncodeandDecodemanually
Documentation
For detailed documentation, see the OxiCode crate documentation.
License
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
Contributing
Contributions are welcome! Please see the main repository for contribution guidelines.