Module io

Source
Expand description

The io module contains implementations of these traits for bytes::Buf and bytes::BufMut.

Example:

use binary_util::io::ByteReader;
use bytes::{Buf, BufMut, BytesMut, Bytes};

fn main() {
   const VARINT: &[u8] = &[255, 255, 255, 255, 7]; // 2147483647
   let mut buf = ByteReader::from(&VARINT[..]);
   assert_eq!(buf.read_var_u32().unwrap(), 2147483647);
}

Structs§

ByteReader
ByteReader is a panic-free way to read bytes from the byte::Buf trait.
ByteWriter
ByteWriter is a panic-free way to write bytes to a BufMut trait.

Constants§

ERR_EOB
ERR_EOM
ERR_VARINT_TOO_LONG