Crate serde_binary_adv

Crate serde_binary_adv 

Source
Expand description

§Serde Binary Advanced

Serde Binary Advanced is a Serde library enabling the serialization and deserialization of Rust objects to and from binary representations.

§Features

  • Serialization and deserialization of Rust data structures to and from raw binary format
  • Full support for all Rust native types
  • Comprehensive error reporting

§Installation

Add this to your Cargo.toml:

[dependencies]
serde = { version = "1", features = ["derive"] }
serde_binary_adv = { version = "1" }

§Usage

Here’s a quick example on how to use Serde Binary Advanced to serialize and deserialize a struct to and from binary:

use serde::{Serialize, Deserialize};

struct Point {
    x: i64,
    y: i64,
}

fn main() -> Result<(),Error> {
    let point = Point { x: 1.0, y: 2.0 };

    // Serialize to bytes
    let raw: Vec<u8> = serde_binary_adv::to_bytes(&point)?;
    assert_eq!(raw, vec![0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02]);

    // Deserialize from bytes
    let deserialized_point: Point = serde_yml::from_bytes(&raw)?;
    assert_eq!(point, deserialized_point);

    Ok(())
}

Serde Binary Advanced is copyright © 2025 JEleniel and released under either The MIT License or The Apache License, at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you shall be licensed as above, without any additional terms or conditions.

Modules§

stream
Versions of the Serde Binary Advanced Serializer and Deserializer optimized for use with streams that implement Read/Write

Structs§

Deserializer
Deserializes binary data into Rust types
Serializer
A structure for serializing Rust values into binary.

Enums§

BinaryError
Errors that can be thrown by the Serializer or Deserializer
ByteFormat
How to serialize multibyte sequences (e.g. u128, i128, f64)

Type Aliases§

Result
an Ok(()) or Err(serde_binary_adv::BinaryError)