pub trait VarLongRead: Read {
// Provided methods
fn read_varlong(&mut self) -> Result<i64, CodecError> { ... }
fn read_varlong_with_size(&mut self) -> Result<(i64, usize), CodecError> { ... }
}Expand description
Extension methods for reading Minecraft protocol VarLong values.
This trait is implemented for every Read type.
§Example
use mcproto_codec::varlong::{VarLongRead, VarLongWrite};
let mut encoded = Vec::new();
encoded.write_varlong(9_223_372_036_854_775_000)?;
let value = encoded.as_slice().read_varlong()?;
assert_eq!(value, 9_223_372_036_854_775_000);
Provided Methods§
Sourcefn read_varlong(&mut self) -> Result<i64, CodecError>
fn read_varlong(&mut self) -> Result<i64, CodecError>
Reads and returns one VarLong from this reader.
§Errors
Returns a CodecError if the input ends early, the underlying reader
fails, or the input is not a valid VarLong.
Sourcefn read_varlong_with_size(&mut self) -> Result<(i64, usize), CodecError>
fn read_varlong_with_size(&mut self) -> Result<(i64, usize), CodecError>
Reads one VarLong and returns its value and encoded size in bytes.
§Errors
Returns a CodecError if the input ends early, the underlying reader
fails, or the input is not a valid VarLong.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".