pub trait ReadVarInt: Read {
// Provided method
fn read_varint<T: VarInt>(&mut self) -> Result<T> { ... }
}Expand description
Extension trait for reading variable-length integers.
Implemented automatically for every type implementing Read.
§Example
use std::io::Cursor;
use orengine_utils::varint::{ReadVarInt, WriteVarInt};
let mut data = Vec::new();
data.write_varint(500u32).unwrap();
let mut reader = Cursor::new(data);
let value: u32 = reader.read_varint().unwrap();
assert_eq!(value, 500);Provided Methods§
Sourcefn read_varint<T: VarInt>(&mut self) -> Result<T>
fn read_varint<T: VarInt>(&mut self) -> Result<T>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".