Expand description
§Qubit Binary IO
Synchronous and asynchronous binary stream I/O adapters for Rust.
Synchronous APIs operate on qubit_io::Input and
qubit_io::Output. Runtime-neutral asynchronous extension traits operate
on qubit_io::AsyncInput and qubit_io::AsyncOutput. Both layers reuse
the same codec implementations for fixed-width values, LEB128, ZigZag, and
length-prefixed UTF-8 strings.
This crate combines qubit-io stream helpers with
qubit-codec-binary buffer codecs to provide binary reader and writer
extension traits and wrapper types.
§Asynchronous extension traits
Async extension methods are runtime-neutral and only require Unpin
inputs and outputs:
use qubit_io::{
AsyncInput,
AsyncOutput,
};
use qubit_io_binary::{
AsyncBinaryReadExt,
AsyncBinaryWriteExt,
};
async fn relay<I, O>(input: &mut I, output: &mut O) -> std::io::Result<()>
where
I: AsyncInput<Item = u8> + Unpin,
O: AsyncOutput<Item = u8> + Unpin,
{
let value = input.read_u32_be_async().await?;
output.write_u32_be_async(value).await
}Modules§
- prelude
- Common binary I/O extension traits.
Structs§
- Binary
Reader - Reader wrapper for fixed-width binary values.
- Binary
Writer - Writer wrapper for fixed-width binary values.
- Buffered
Binary Reader - Buffered reader for fixed-width binary values.
- Buffered
Binary Writer - Buffered writer for fixed-width binary values.
- Buffered
Leb128 Reader - Buffered reader for LEB128 integers.
- Buffered
Leb128 Writer - Buffered writer for canonical LEB128 integers.
- Buffered
ZigZag Reader - Buffered reader for ZigZag + unsigned LEB128 integers.
- Buffered
ZigZag Writer - Buffered writer for canonical ZigZag + unsigned LEB128 integers.
- Leb128
Reader - Reader wrapper for LEB128 integers.
- Leb128
Writer - Writer wrapper for canonical LEB128 integers.
- ZigZag
Reader - Reader wrapper for ZigZag + unsigned LEB128 integers.
- ZigZag
Writer - Writer wrapper for canonical ZigZag + unsigned LEB128 integers.
Traits§
- Async
Binary Read Ext - Future-based fixed-width binary reads from runtime-neutral async inputs.
- Async
Binary Write Ext - Future-based fixed-width binary writes to runtime-neutral async outputs.
- Async
Leb128 Read Ext - Future-based LEB128 integer reads from runtime-neutral async inputs.
- Async
Leb128 Write Ext - Future-based canonical LEB128 writes to runtime-neutral async outputs.
- Async
String Read Ext - Future-based length-prefixed UTF-8 reads.
- Async
String Write Ext - Future-based length-prefixed UTF-8 writes.
- Async
ZigZag Read Ext - Future-based ZigZag plus unsigned-LEB128 reads.
- Async
ZigZag Write Ext - Future-based ZigZag plus unsigned-LEB128 writes.
- Binary
Read Ext - Extension methods for reading fixed-width binary values from byte streams.
- Binary
Write Ext - Extension methods for writing fixed-width binary values to byte streams.
- Leb128
Read Ext - Extension methods for reading LEB128 integers from byte streams.
- Leb128
Write Ext - Extension methods for writing canonical LEB128 integers to byte streams.
- String
Read Ext - Extension methods for reading length-prefixed UTF-8 strings.
- String
Write Ext - Extension methods for writing length-prefixed UTF-8 strings.
- ZigZag
Read Ext - Extension methods for reading ZigZag + unsigned LEB128 integers.
- ZigZag
Write Ext - Extension methods for writing ZigZag + unsigned LEB128 integers.