Expand description
§OxiCode
OxiCode is a modern binary serialization library for Rust, serving as the successor to bincode.
It provides a compact, efficient binary encoding scheme with zero-fluff serialization. The encoded size is typically equal to or smaller than the in-memory representation.
§Features
- Compact encoding: Minimal overhead in serialized format
- Fast: Optimized for performance
- Flexible: Support for various encoding configurations
- Safe: No unwrap() policy, comprehensive error handling
- Modern: Built with latest Rust practices and patterns
§Example
ⓘ
use oxicode::{Encode, Decode};
#[derive(Encode, Decode, PartialEq, Debug)]
struct Point {
x: f32,
y: f32,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let point = Point { x: 1.0, y: 2.0 };
// Encode to bytes
let encoded = oxicode::encode(&point)?;
// Decode from bytes
let decoded: Point = oxicode::decode(&encoded)?;
assert_eq!(point, decoded);
Ok(())
}§Relation to bincode
OxiCode is designed as the spiritual successor to bincode, maintaining compatibility with the core concepts while introducing modern improvements and best practices.
Re-exports§
pub use de::BorrowDecode;pub use de::BufferedIoReader;stdpub use de::Decode;pub use display::EncodedBytes;pub use display::EncodedBytesOwned;allocpub use enc::Encode;pub use error::Error;pub use error::Result;
Modules§
- async_
io async-tokio - Convenience re-exports for async IO streaming (alias of
crate::async_tokio). - async_
tokio async-tokio - Convenience re-exports for async tokio streaming.
- checksum
checksum - CRC32 checksum/integrity verification for OxiCode.
- compression
compression-lz4orcompression-zstd - Built-in compression support for oxicode.
- config
- The config module is used to change the behavior of oxicode’s encoding and decoding logic.
- de
- Decoder-based structs and traits
- display
- Display utilities for encoded binary data.
- enc
- Encoder-based structs and traits
- error
- Error types for OxiCode
- serde
serde - Serde compatibility layer
- simd
simd - SIMD-optimized encoding and decoding for oxicode.
- streaming
alloc - Streaming serialization support for oxicode.
- validation
- Validation middleware for oxicode.
- versioning
- Schema versioning and evolution support for oxicode.
Macros§
- impl_
borrow_ decode - Helper macro to implement BorrowDecode for types that implement Decode. This is useful for types that don’t need to borrow from the input.
Structs§
- Decode
Iter alloc - An iterator that lazily decodes items from an encoded sequence.
Functions§
- borrow_
decode_ from_ slice - Borrow decode a value from a byte slice (zero-copy) using the standard configuration.
- borrow_
decode_ from_ slice_ with_ config - Borrow decode a value from a byte slice (zero-copy) with custom configuration
- decode_
from_ buffered_ read std - Decode a value from any
std::io::Readusing an internal 8 KiB buffer. - decode_
from_ de_ reader - Decode a value from an oxicode
de::Readerusing the given configuration. - decode_
from_ file std - Decode a value from a file using the standard configuration
- decode_
from_ file_ with_ config std - Decode a value from a file with a custom configuration
- decode_
from_ hex std - Decode a value from a hex string (lowercase or uppercase) using default config.
- decode_
from_ reader std - Decode a value from any
std::io::Readimplementor using the standard configuration. - decode_
from_ reader_ with_ config std - Decode a value from any
std::io::Readusing a custom configuration. - decode_
from_ slice - Decode a value from a byte slice using the standard configuration.
- decode_
from_ slice_ checked checksumandalloc - Decode a value from bytes that were encoded with
encode_to_vec_checked. - decode_
from_ slice_ with_ config - Decode a value from a byte slice with a custom configuration.
- decode_
from_ slice_ with_ context - Decode a value from a byte slice with custom context
- decode_
from_ std_ read std - Decode a value from a
std::io::Readusing the given configuration. - decode_
iter_ from_ slice alloc - Decode a sequence lazily, yielding items one at a time without loading all into memory.
- decode_
iter_ from_ slice_ with_ config alloc - Decode a sequence lazily with a custom configuration.
- decode_
value - Convenience: decode a value from a byte slice using the standard config, discarding the consumed byte count.
- decode_
versioned_ value alloc - Decode a versioned value, returning
(value, version, bytes_consumed). - encode_
bytes alloc - Convenience: encode a value to
Vec<u8>using the standard config. - encode_
copy alloc - Encode a
Copyvalue into aVec<u8>using default config. Unlikeencode_to_vecwhich takes&E, this takesEby value. - encode_
into_ slice - Encode a value into a byte slice.
- encode_
into_ std_ write std - Encode a value into a
std::io::Writeusing the given configuration. - encode_
into_ writer - Encode a value into a writer using the given configuration.
- encode_
iter_ to_ vec alloc - Encode an iterator of items as a length-prefixed sequence into a
Vec<u8>. - encode_
iter_ to_ vec_ with_ config alloc - Encode an iterator of items as a length-prefixed sequence into a
Vec<u8>with a custom configuration. - encode_
seq_ into_ slice - Encode an exact-size iterator into a pre-allocated byte slice.
- encode_
seq_ into_ slice_ with_ config - Encode an exact-size iterator into a pre-allocated byte slice with a custom configuration.
- encode_
seq_ to_ vec alloc - Encode an exact-size iterator as a length-prefixed sequence into a
Vec<u8>. - encode_
seq_ to_ vec_ with_ config alloc - Encode an exact-size iterator as a length-prefixed sequence into a
Vec<u8>with a custom configuration. - encode_
to_ display alloc - Encode a value and return it wrapped for human-readable display.
- encode_
to_ file std - Encode a value to a file using the standard configuration
- encode_
to_ file_ with_ config std - Encode a value to a file with a custom configuration
- encode_
to_ fixed_ array - Encode a value into a fixed-size stack-allocated array using the standard configuration.
- encode_
to_ fixed_ array_ with_ config - Encode a value into a fixed-size stack-allocated array with a custom configuration.
- encode_
to_ hex std - Encode
valueto a lowercase hex string using default config. - encode_
to_ vec alloc - Encode a value to a
Vec<u8>using the standard configuration. - encode_
to_ vec_ checked checksumandalloc - Encode a value to a
Vec<u8>with a CRC32 checksum header appended, using default config. - encode_
to_ vec_ with_ config alloc - Encode a value to a
Vec<u8>with a custom configuration. - encode_
to_ vec_ with_ size_ hint std - Encode
valueinto aVec<u8>with a pre-allocated size hint. - encode_
to_ writer std - Encode
valueinto anystd::io::Writeimplementor using the standard configuration. - encode_
to_ writer_ with_ config std - Encode
valueinto anystd::io::Writeusing a custom configuration. - encode_
versioned_ value alloc - Encode a value with a version header for forward-compatible storage.
- encoded_
bytes - Wrap a byte slice for human-readable display.
- encoded_
size - Calculate the encoded size of a value using the standard configuration.
- encoded_
size_ with_ config - Calculate the encoded size of a value with a custom configuration.
Derive Macros§
- Borrow
Decode derive - Derive macro for the
BorrowDecodetrait - Decode
derive - Derive macro for the
Decodetrait - Encode
derive - Derive macro for the
Encodetrait