Expand description
Common traits and helper macros for binary encoding and decoding.
This crate provides common Encode
and Decode
traits for describing binary encode/decode-able objects, as well as #[derive(Encode)]
and #[derive(Decode)]
macros to reduce boilerplate when propagating these and little-endian implementations for primitive types.
For more implementation see the module-level documentation.
This is intended to provide a reusable base for implementing binary encodable objects to match a particular protocol or specification (and mitigate embedded pub trait (Encode|Decode) {..}
bankruptcy)
If you don’t need to control the encoded layout directly you might like to look at serde, with postcard for efficient binary encoding between rust components. If you’re creating a new protocol for cross-language use you may wish to consider creating a specification using protocol buffers and prost.
Modules§
- decode
Decode
traits and helper macros- derive
- Macros for deriving primitive
Decode
andEncode
implementations on types containing decodable/encodable fields. - encode
Encode
traits and helper macros- helpers
- Helpers for testing encode/decode objects as well as specialised encode/decode impls
Enums§
- Error
- Basic encode/decode error type
Traits§
- Decode
- Decode trait implemented for binary decodable objects
- Decode
Ext - Extensions to
Decode
trait for decodable objects - Decode
Owned - Decode trait implemented for owned types
- EncDec
- Composite trait requiring an object is reversibly encodable and decodable into borrowed types, useful for simplifying type bounds / generics.
- EncDec
Owned - Composite trait requiring an object is reversibly encodable and decodable into owned types, useful for simplifying type bounds / generics.
- Encode
- Encode trait implemented for binary encodable objects
- Encode
Ext - Extensions to
Encode
trait for encodable types
Derive Macros§
- Decode
#[derive(Decode)]
support.- Decode
Owned #[derive(DecodeOwned)]
support.- Encode
#[derive(Encode)]
support.