#c #primitive #arrays #array #read #bad-idea


A Rust library for zero-allocation parsing of binary data

4 releases

0.1.3 Nov 27, 2022
0.1.2 Jan 17, 2016
0.1.1 Jan 17, 2016
0.1.0 Jan 16, 2016

#52 in Parser tooling

Download history 4908/week @ 2023-08-01 5319/week @ 2023-08-08 5400/week @ 2023-08-15 5521/week @ 2023-08-22 4970/week @ 2023-08-29 5795/week @ 2023-09-05 5329/week @ 2023-09-12 4779/week @ 2023-09-19 5069/week @ 2023-09-26 5650/week @ 2023-10-03 4531/week @ 2023-10-10 4952/week @ 2023-10-17 4893/week @ 2023-10-24 4996/week @ 2023-10-31 5285/week @ 2023-11-07 4299/week @ 2023-11-14

20,288 downloads per month
Used in 41 crates (5 directly)

Apache-2.0 OR MIT

228 lines


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.


cargo build


cargo test

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

zero = "0.1.2"


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 UTF-8 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 and aligned. The string functions check that strings are valid UTF-8. There is no checking that the provided 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