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

#97 in Parser tooling

Download history 4239/week @ 2023-12-16 3159/week @ 2023-12-23 4737/week @ 2023-12-30 4707/week @ 2024-01-06 4901/week @ 2024-01-13 4775/week @ 2024-01-20 4975/week @ 2024-01-27 4775/week @ 2024-02-03 4994/week @ 2024-02-10 4779/week @ 2024-02-17 6047/week @ 2024-02-24 5568/week @ 2024-03-02 5854/week @ 2024-03-09 5275/week @ 2024-03-16 5314/week @ 2024-03-23 4992/week @ 2024-03-30

22,447 downloads per month
Used in 45 crates (5 directly)

Apache-2.0 OR MIT

13KB
228 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 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