#zero #binary #data #binary-data #zero-allocation

zero

A Rust library for zero-allocation parsing of binary data

3 releases

Uses old Rust 2015

0.1.2 Jan 17, 2016
0.1.1 Jan 17, 2016
0.1.0 Jan 16, 2016
Download history 1034/week @ 2020-12-18 977/week @ 2020-12-25 1133/week @ 2021-01-01 1440/week @ 2021-01-08 1079/week @ 2021-01-15 1165/week @ 2021-01-22 1204/week @ 2021-01-29 1042/week @ 2021-02-05 1056/week @ 2021-02-12 1101/week @ 2021-02-19 1268/week @ 2021-02-26 1142/week @ 2021-03-05 1190/week @ 2021-03-12 1236/week @ 2021-03-19 1422/week @ 2021-03-26 1716/week @ 2021-04-02

4,807 downloads per month
Used in 26 crates (4 directly)

Apache-2.0/MIT

11KB
192 lines

Zero

A Rust library for zero-allocation parsing of binary data.

Requires Rust version 1.6 or later (requires stable libcore for no_std).

See docs for more information.

Available on crates.io.

Build:

cargo build

Test:

cargo test

To use in your project, add to your Cargo.toml:

[dependencies]
zero = "0.1.2"

lib.rs:

Functions for reading binary data into Rust data structures. All functions are zero-allocation.

There are functions for reading a single value, an array of values, a single null-terminated utf8 string (which should also work with ascii strings), and an array of null-terminated strings terminated by another null byte.

Functions preserve the lifetime of the underlying data. These functions are memory safe, although this is in part based on the assumption that the client only implements the unsafe trait Pod where safe to do so.

Functions assert that the provided data is large enough. The string functions check that strings are valid utf8. There is no checking that the the privided input will produce a valid object (for example, an enum has a valid discriminant). The user must assert this by implementing the trait Pod.

There are also unsafe versions of most functions which do not require the return type to implement Pod and which do no checking.

No runtime deps