Module binary_util::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 is a panic-free way to read bytes from the byte::Buf trait.
  • ByteWriter is a panic-free way to write bytes to a BufMut trait.

Constants