#byte #serialization #buffer #deserialize #data #slice #peek

peek-poke

A mechanism for serializing and deserializing data into/from byte buffers, for use in WebRender

1 unstable release

0.2.0 Jan 15, 2020

#1315 in Parser implementations

Download history 238/week @ 2023-11-23 120/week @ 2023-11-30 183/week @ 2023-12-07 263/week @ 2023-12-14 236/week @ 2023-12-21 108/week @ 2023-12-28 164/week @ 2024-01-04 242/week @ 2024-01-11 207/week @ 2024-01-18 141/week @ 2024-01-25 121/week @ 2024-02-01 254/week @ 2024-02-08 290/week @ 2024-02-15 218/week @ 2024-02-22 236/week @ 2024-02-29 203/week @ 2024-03-07

980 downloads per month
Used in 15 crates (via webrender_api)

MIT/Apache

25KB
439 lines

Peeks, Pokes, and Pointers

Peek from and poke structures into byte slices.

Benchmark

Below are the benchmark results of comparison between peek-poke and bincode serializing and deserializing same struct:

struct MyPeekPokeStruct {
    a: u8,
    b: u16,
    c: MyPeekPokeEnum,
    d: Option<usize>,
}

enum MyPeekPokeEnum {
    Variant1,
    Variant2(u16),
}
Benchmarking struct::serialize/peek_poke::poke_into: Collecting 100 samples in                                                                                struct::serialize/peek_poke::poke_into
                        time:   [2.7267 ns 2.7321 ns 2.7380 ns]

Benchmarking struct::serialize/bincode::serialize: Collecting 100 samples in est                                                                                struct::serialize/bincode::serialize
                        time:   [31.264 ns 31.326 ns 31.389 ns]

Benchmarking struct::deserialize/peek_poke::peek_from: Collecting 100 samples                                                                                 struct::deserialize/peek_poke::peek_from
                        time:   [5.3544 ns 5.3672 ns 5.3817 ns]

Benchmarking struct::deserialize/bincode::deserialize: Collecting 100 samples in                                                                                struct::deserialize/bincode::deserialize
                        time:   [25.155 ns 26.439 ns 27.661 ns]

You can run benchmarks by running following command:

cargo bench

License

Licensed under either of

at your option.

see LICENSE-APACHE, LICENSE-MIT for details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as about, without any additional terms or conditions.

Dependencies

~0–370KB