Skip to main content

Crate qubit_io_binary

Crate qubit_io_binary 

Source
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§

BinaryReader
Reader wrapper for fixed-width binary values.
BinaryWriter
Writer wrapper for fixed-width binary values.
BufferedBinaryReader
Buffered reader for fixed-width binary values.
BufferedBinaryWriter
Buffered writer for fixed-width binary values.
BufferedLeb128Reader
Buffered reader for LEB128 integers.
BufferedLeb128Writer
Buffered writer for canonical LEB128 integers.
BufferedZigZagReader
Buffered reader for ZigZag + unsigned LEB128 integers.
BufferedZigZagWriter
Buffered writer for canonical ZigZag + unsigned LEB128 integers.
Leb128Reader
Reader wrapper for LEB128 integers.
Leb128Writer
Writer wrapper for canonical LEB128 integers.
ZigZagReader
Reader wrapper for ZigZag + unsigned LEB128 integers.
ZigZagWriter
Writer wrapper for canonical ZigZag + unsigned LEB128 integers.

Traits§

AsyncBinaryReadExt
Future-based fixed-width binary reads from runtime-neutral async inputs.
AsyncBinaryWriteExt
Future-based fixed-width binary writes to runtime-neutral async outputs.
AsyncLeb128ReadExt
Future-based LEB128 integer reads from runtime-neutral async inputs.
AsyncLeb128WriteExt
Future-based canonical LEB128 writes to runtime-neutral async outputs.
AsyncStringReadExt
Future-based length-prefixed UTF-8 reads.
AsyncStringWriteExt
Future-based length-prefixed UTF-8 writes.
AsyncZigZagReadExt
Future-based ZigZag plus unsigned-LEB128 reads.
AsyncZigZagWriteExt
Future-based ZigZag plus unsigned-LEB128 writes.
BinaryReadExt
Extension methods for reading fixed-width binary values from byte streams.
BinaryWriteExt
Extension methods for writing fixed-width binary values to byte streams.
Leb128ReadExt
Extension methods for reading LEB128 integers from byte streams.
Leb128WriteExt
Extension methods for writing canonical LEB128 integers to byte streams.
StringReadExt
Extension methods for reading length-prefixed UTF-8 strings.
StringWriteExt
Extension methods for writing length-prefixed UTF-8 strings.
ZigZagReadExt
Extension methods for reading ZigZag + unsigned LEB128 integers.
ZigZagWriteExt
Extension methods for writing ZigZag + unsigned LEB128 integers.