24 releases

new 0.1.29 Nov 1, 2024
0.1.28 Aug 6, 2024
0.1.27 Jul 18, 2024
0.1.23 Jun 24, 2024
0.1.4 Apr 25, 2024

#1245 in Encoding

MIT/Apache

49KB
1K SLoC

derse

Rust Crates.io Version codecov

A simple binary serialization protocol for Rust.

Usage

To use this library, add the following to your Cargo.toml:

[dependencies]
derse = "0.1"

Then, you can import and use the components as follows:

use derse::{Deserialize, DownwardBytes, Serialize};

// 1. serialization for basic types.
let ser = "hello world!";
let bytes = ser.serialize::<DownwardBytes>().unwrap();
let der = String::deserialize(&bytes[..]).unwrap();
assert_eq!(ser, der);

// 2. serialization for custom structs.
#[derive(Debug, Default, Deserialize, Serialize, PartialEq)]
pub struct Demo {
    a: i32,
    b: String,
    c: Vec<String>,
}
let ser = Demo::default();
let bytes = ser.serialize::<DownwardBytes>().unwrap();
let der = Demo::deserialize(&bytes[..]).unwrap();
assert_eq!(ser, der);

Dependencies

~1.4–2.1MB
~43K SLoC