7 releases
0.0.7 | Jan 29, 2023 |
---|---|
0.0.6 | Jan 28, 2023 |
#699 in Asynchronous
26 downloads per month
Used in 2 crates
120KB
2K
SLoC
tokio-bitstream-io
Tokio port of bitstream-io
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 tokio AsyncRead
or AsyncWrite
traits.
It also supports a wide array of integer data types as
containers for those binary values.
lib.rs
:
Port of bitstream_io for usage with tokio runtime
Traits and helpers for async bitstream handling functionality
Async 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 tokio AsyncRead
trait, and the only requirement
for writer streams is that they must implement tokio AsyncWrite
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.
Traits are implemented with async_trait macro that is re-exported from this library
Dependencies
~2.2–4MB
~63K SLoC