16 releases (9 breaking)

0.10.0 Feb 9, 2024
0.9.0 Nov 17, 2023
0.8.0 Nov 14, 2023
0.7.0 Oct 10, 2022
0.2.1 Feb 11, 2022

#34 in #binary-serialization

Download history 708/week @ 2023-12-18 210/week @ 2023-12-25 423/week @ 2024-01-01 1355/week @ 2024-01-08 1303/week @ 2024-01-15 2149/week @ 2024-01-22 1104/week @ 2024-01-29 1746/week @ 2024-02-05 1538/week @ 2024-02-12 2178/week @ 2024-02-19 1321/week @ 2024-02-26 1233/week @ 2024-03-04 1019/week @ 2024-03-11 1197/week @ 2024-03-18 1012/week @ 2024-03-25 857/week @ 2024-04-01

4,134 downloads per month
Used in 17 crates (via packable)


742 lines

Packable is a binary serialization and deserialization framework.


Values of a type can be serialized and deserialized if the type implements the Packable trait. The serialization strategy used for each type is up to the user. However, Packable can also be derived, this provides a consistent serialization strategy.

For more information about the design of this crate please read the Packable, unpacker, packer, UnpackError and UnpackErrorExt documentation.

no_std compatibility

Packable is no_std compatible. This is achieved by introducing the Packer and Unpacker traits to abstract away any IO operation without relying on std::io. This has the additional benefit of allowing us to pack and unpack values from different kinds of buffers.

Types that implement Packable

The Packable trait is implemented for every sized integer type by encoding the value as an array of bytes in little-endian order.

Booleans are packed following Rust's data layout, meaning that true is packed as a 1 byte and false as a 0 byte. However, boolean unpacking is less strict and unpacks any non-zero byte as true.

Types such as Box<[T]>, [T; N] and Option<T> implement Packable if T implements Packable.

This crate also provides bounded integers under the bounded module which have additional syntactical checks to guarantee that the deserialized values are in-bounds. It is also possible to serialize and deserialize sequences of values by using the types provided in the prefix module, which represent linear sequences of values with a length prefix.

Check the Packable impl section for further information.



This feature provides the types IoPacker and IoUnpacker which allow packing and unpacking from values whose types implement Write and Read respectively.


This feature implements Packable for U256 encoding its values as arrays of bytes in little-endian order.


This feature derives Serialize and Deserialize for the types provided in the bounded and prefix modules


This feature implements Error for all the error types provided by this crate.


This feature implements Packable for usize, isize, Vec<T>, Box<[T]> and String. This is done serializing and deserializing pointer sized integers as 64-bit integers. This feature will not work for targets with a pointer width larger than 64.

License: Apache-2.0


~57K SLoC