#bitstream #endian #big-endian #little-endian #binary


Library for reading/writing un-aligned values from/to streams in big-endian and little-endian formats

18 releases

✓ Uses Rust 2018 edition

0.8.5 Mar 17, 2020
0.8.4 Aug 15, 2019
0.8.3 Jul 11, 2019
0.8.2 Dec 17, 2018
0.6.1 Mar 27, 2017

#47 in Network programming

Download history 1068/week @ 2019-12-10 1009/week @ 2019-12-17 596/week @ 2019-12-24 710/week @ 2019-12-31 1113/week @ 2020-01-07 1172/week @ 2020-01-14 787/week @ 2020-01-21 552/week @ 2020-01-28 686/week @ 2020-02-04 720/week @ 2020-02-11 658/week @ 2020-02-18 705/week @ 2020-02-25 767/week @ 2020-03-03 627/week @ 2020-03-10 1290/week @ 2020-03-17 660/week @ 2020-03-24

3,329 downloads per month
Used in 17 crates (12 directly)




A Rust library for reading or writing binary values to or from streams which may not be aligned at a whole byte.

This library is intended to be flexible enough to wrap around any stream which implements the Read or Write traits. It also supports a wide array of integer data types as containers for those binary values.



Add this to your Cargo.toml:

bitstream-io = "0.8"

and this to your crate root:

extern crate bitstream_io;


Traits and helpers for bitstream handling functionality

Bitstream readers are for reading signed and unsigned integer values from a stream whose sizes may not be whole bytes. Bitstream writers are for writing signed and unsigned integer values to a stream, also potentially un-aligned at a whole byte.

Both big-endian and little-endian streams are supported.

The only requirement for wrapped reader streams is that they must implement the Read trait, and the only requirement for writer streams is that they must implement the Write trait.

In addition, reader streams do not consume any more bytes from the underlying reader than necessary, buffering only a single partial byte as needed. Writer streams also write out all whole bytes as they are accumulated.

Readers and writers are also designed to work with integer types of any possible size. Many of Rust's built-in integer types are supported by default.

No runtime deps