Crates.io | minecraft-varint |
lib.rs | minecraft-varint |
version | 0.2.0 |
source | src |
created_at | 2020-04-22 00:49:37.37753 |
updated_at | 2021-11-13 03:17:51.863516 |
description | Minecraft's VarInt and VarLong implemetation in Rust, providing minimum memory usage and maximum performance. |
homepage | |
repository | https://github.com/belohnung/minecraft-varint |
max_upload_size | |
id | 232757 |
size | 8,715 |
Minecraft VarInt and VarLong implemetation in Rust, providing minimum memory usage and maximum performance.
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);
}
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]);
}