Skip to main content

Crate oxicode

Crate oxicode 

Source
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;std
pub use de::Decode;
pub use display::EncodedBytes;
pub use display::EncodedBytesOwned;alloc
pub use enc::Encode;
pub use error::Error;
pub use error::Result;

Modules§

async_ioasync-tokio
Convenience re-exports for async IO streaming (alias of crate::async_tokio).
async_tokioasync-tokio
Convenience re-exports for async tokio streaming.
checksumchecksum
CRC32 checksum/integrity verification for OxiCode.
compressioncompression-lz4 or compression-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
serdeserde
Serde compatibility layer
simdsimd
SIMD-optimized encoding and decoding for oxicode.
streamingalloc
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§

DecodeIteralloc
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_readstd
Decode a value from any std::io::Read using an internal 8 KiB buffer.
decode_from_de_reader
Decode a value from an oxicode de::Reader using the given configuration.
decode_from_filestd
Decode a value from a file using the standard configuration
decode_from_file_with_configstd
Decode a value from a file with a custom configuration
decode_from_hexstd
Decode a value from a hex string (lowercase or uppercase) using default config.
decode_from_readerstd
Decode a value from any std::io::Read implementor using the standard configuration.
decode_from_reader_with_configstd
Decode a value from any std::io::Read using a custom configuration.
decode_from_slice
Decode a value from a byte slice using the standard configuration.
decode_from_slice_checkedchecksum and alloc
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_readstd
Decode a value from a std::io::Read using the given configuration.
decode_iter_from_slicealloc
Decode a sequence lazily, yielding items one at a time without loading all into memory.
decode_iter_from_slice_with_configalloc
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_valuealloc
Decode a versioned value, returning (value, version, bytes_consumed).
encode_bytesalloc
Convenience: encode a value to Vec<u8> using the standard config.
encode_copyalloc
Encode a Copy value into a Vec<u8> using default config. Unlike encode_to_vec which takes &E, this takes E by value.
encode_into_slice
Encode a value into a byte slice.
encode_into_std_writestd
Encode a value into a std::io::Write using the given configuration.
encode_into_writer
Encode a value into a writer using the given configuration.
encode_iter_to_vecalloc
Encode an iterator of items as a length-prefixed sequence into a Vec<u8>.
encode_iter_to_vec_with_configalloc
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_vecalloc
Encode an exact-size iterator as a length-prefixed sequence into a Vec<u8>.
encode_seq_to_vec_with_configalloc
Encode an exact-size iterator as a length-prefixed sequence into a Vec<u8> with a custom configuration.
encode_to_displayalloc
Encode a value and return it wrapped for human-readable display.
encode_to_filestd
Encode a value to a file using the standard configuration
encode_to_file_with_configstd
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_hexstd
Encode value to a lowercase hex string using default config.
encode_to_vecalloc
Encode a value to a Vec<u8> using the standard configuration.
encode_to_vec_checkedchecksum and alloc
Encode a value to a Vec<u8> with a CRC32 checksum header appended, using default config.
encode_to_vec_with_configalloc
Encode a value to a Vec<u8> with a custom configuration.
encode_to_vec_with_size_hintstd
Encode value into a Vec<u8> with a pre-allocated size hint.
encode_to_writerstd
Encode value into any std::io::Write implementor using the standard configuration.
encode_to_writer_with_configstd
Encode value into any std::io::Write using a custom configuration.
encode_versioned_valuealloc
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§

BorrowDecodederive
Derive macro for the BorrowDecode trait
Decodederive
Derive macro for the Decode trait
Encodederive
Derive macro for the Encode trait