exbytes 0.1.2

Extensions for `bytes::Bytes` and `bytes::BytesMut` to support variable-length integer encoding (LEB128/ZigZag)
Documentation
  • Coverage
  • 100%
    30 out of 30 items documented0 out of 27 items with examples
  • Size
  • Source code size: 39.62 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 424.56 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • localvoid/exbytes
    0 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • localvoid

exbytes

Extensions for bytes providing variable-length integer encoding via LEB128 (unsigned) and ZigZag (signed).

Usage

use bytes::BytesMut;
use exbytes::{BytesMutExt as _, BytesExt as _};

let mut buf = BytesMut::new();
buf.put_vu32(42u32);
buf.put_zz32(-7i32);

let mut view = buf.freeze();
let a = view.get_vu32();   // 42
let b = view.get_zz32();   // -7

Fallible decoding is also available via try_get_* methods:

let mut buf: &[u8] = &[0x80, 0x01];
let n = buf.try_get_vu16()?;  // 128

Supported types

Encoding get / put try_get
LEB128 vu16, vu32, vu64, vu128 try_get_vu16, …, try_get_vu128
ZigZag zz16, zz32, zz64, zz128 try_get_zz16, …, try_get_zz128

License

MIT or Apache-2.0