minecraft-varint 0.2.0

Minecraft's VarInt and VarLong implemetation in Rust, providing minimum memory usage and maximum performance.
Documentation
  • Coverage
  • 0%
    0 out of 11 items documented0 out of 10 items with examples
  • Size
  • Source code size: 8.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.19 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • belohnung/minecraft-varint
    10 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • belohnung

minecaft-varint

Minecraft VarInt and VarLong implemetation in Rust, providing minimum memory usage and maximum performance.

Crates.io WTFPL licensed

Example

Read a VarInt from a Read

use mc_varint::VarIntRead;
use std::io::Cursor;
fn main() {
    // firstly we create a Cursor
    let mut cur = Cursor::new(vec![0xff, 0xff, 0xff, 0xff, 0x07]);
    // secondly we read from it
    let value = cur.read_var_i32().unwrap();
    // the value is 2147483647
    assert_eq!(value, 2147483647);
}

Write a VarInt to a Write

use mc_varint::{VarInt, VarIntWrite};
use std::io::Cursor;
fn main() {
    // firstly we create a Cursor and a VarInt
    let mut cur = Cursor::new(Vec::with_capacity(5));
    // secondly we write the VarInt to the Cursor
    cur.write_var_i32(2147483647).unwrap();
    // now the value is written to cur.
    assert_eq!(cur.into_inner(), vec![0xff, 0xff, 0xff, 0xff, 0x07]);
}