teeint

Version Downloads License Rust Docs

A teeworlds variable integer packer/unpacker.

Packing

```rust use std::io::Cursor;

let mut buff = Cursor::new([0; 2]);

teeint::pack(&mut buff, 64).unwrap();

let buff = buff.intoinner(); asserteq!(buff[0], 0b10000000); asserteq!(buff[1], 0b0000_0001); ```

Or using the trait [PackTwInt]: ```rust use std::io::Cursor; use teeint::PackTwInt;

let mut buff = Cursor::new([0; 2]);

64.pack(&mut buff).unwrap();

let buff = buff.intoinner(); asserteq!(buff[0], 0b10000000); asserteq!(buff[1], 0b0000_0001); ```

Or ```rust use teeint::PackTwInt;

let mut buff = [0; 2]; 64.pack(&mut buff.asmutslice()).unwrap(); asserteq!(buff[0], 0b10000000); asserteq!(buff[1], 0b00000001); ```

Unpacking

```rust use std::io::Cursor;

let mut buff = Cursor::new([0b10000000, 0b00000001]); let data = teeint::unpack(&mut buff).unwrap(); assert_eq!(data, 64); ```

Or using the trait [UnPackTwInt]: ```rust use teeint::UnPackTwInt;

let buff = [0b10000000, 0b00000001]; let result = buff.asslice().unpack().unwrap(); asserteq!(result, 64); ```

License: MIT OR Apache-2.0