zerocopy

Want to help improve zerocopy? Fill out our user survey!

Fast, safe, compile error. Pick two.

Zerocopy makes zero-cost memory manipulation effortless. We write unsafe so you don't have to.

Overview

Zerocopy provides four core marker traits, each of which can be derived (e.g., #[derive(FromZeroes)]): - FromZeroes indicates that a sequence of zero bytes represents a valid instance of a type - FromBytes indicates that a type may safely be converted from an arbitrary byte sequence - AsBytes indicates that a type may safely be converted to a byte sequence - Unaligned indicates that a type's alignment requirement is 1

Types which implement a subset of these traits can then be converted to/from byte sequences with little to no runtime overhead.

Zerocopy also provides byte-order aware integer types that support these conversions; see the byteorder module. These types are especially useful for network parsing.

Cargo Features

Disclaimer

Disclaimer: Zerocopy is not an officially supported Google product.