26 releases (11 stable)

1.6.4 Sep 5, 2023
1.6.2 Mar 25, 2022
1.5.6 Dec 11, 2021
1.5.5 Jul 8, 2021
0.2.1 Dec 30, 2020

#210 in Rust patterns

Download history 24/week @ 2024-07-22 17/week @ 2024-07-29 16/week @ 2024-08-05 27/week @ 2024-08-12 8/week @ 2024-08-19 55/week @ 2024-08-26 9/week @ 2024-09-02 31/week @ 2024-09-09 4/week @ 2024-09-16 128/week @ 2024-09-23 13/week @ 2024-09-30 17/week @ 2024-10-07 22/week @ 2024-10-14 8/week @ 2024-10-21 2/week @ 2024-10-28 20/week @ 2024-11-04

53 downloads per month
Used in 7 crates (4 directly)

MIT/Apache

64KB
2K SLoC

Fast binary serialization read write,support Serde and Stream model

Similar to bincode, but beyond the performance of bincode

Provide basic RW and var length Rw

let mut data = Data::new();
data.write_fixed(1u8);
data.write_fixed(2i16);
data.write_fixed(3i32);
data.write_fixed(4i64);
data.write_fixed(5f32);
data.write_fixed(6f64);
data.write_fixed("hello world");
data.write_var_integer(123u64);
data.write_var_integer("hello world");

let mut rd = DataReader::from(&data[..]);
assert_eq!(1, rd.read_fixed::<u8>()?);
assert_eq!(2, rd.read_fixed::<i16>()?);
assert_eq!(3, rd.read_fixed::<i32>()?);
assert_eq!(4, rd.read_fixed::<i64>()?);
assert_eq!(5f32, rd.read_fixed::<f32>()?);
assert_eq!(6f64, rd.read_fixed::<f64>()?);
assert_eq!("hello world", rd.read_fixed_str()?);
assert_eq!(123u64, rd.read_var_integer::<u64>()?);
assert_eq!("hello world", rd.read_var_str()?);

Support features custom

[features]
default=["rmp"]
big_endian=[]
check_utf8=[]

benchmark

running 9 tests
test bench_base_rw       ... bench:      52,288 ns/iter (+/- 654)     data-rw
test bench_owned_base_rw ... bench:      53,659 ns/iter (+/- 2,795)   data-rw
test bench_owned_pack    ... bench:     140,562 ns/iter (+/- 1,925)
test bench_pack          ... bench:     139,910 ns/iter (+/- 2,353)
test bench_str           ... bench:      53,023 ns/iter (+/- 770)     data-rw
test bench_str_bincode   ... bench:      71,520 ns/iter (+/- 1,558)
test bench_str_json      ... bench:      91,993 ns/iter (+/- 1,074)
test bench_str_owned     ... bench:      53,272 ns/iter (+/- 1,277)   data-rw
test bench_str_rmp       ... bench:      78,455 ns/iter (+/- 1,333)

test result: ok. 0 passed; 0 failed; 0 ignored; 9 measured; 0 filtered out; finished in 2.24s

Dependencies

~0.4–1.3MB
~28K SLoC