pub trait VarIntWrite: Write {
// Provided methods
fn write_varint(&mut self, value: i32) -> Result<(), CodecError> { ... }
fn write_varint_with_size(
&mut self,
value: i32,
) -> Result<usize, CodecError> { ... }
}Expand description
Extension methods for writing Minecraft protocol VarInt values.
This trait is implemented for every Write type.
§Example
use mcproto_codec::varint::VarIntWrite;
let mut output = Vec::new();
output.write_varint(25565)?;
Provided Methods§
Sourcefn write_varint(&mut self, value: i32) -> Result<(), CodecError>
fn write_varint(&mut self, value: i32) -> Result<(), CodecError>
Writes value to this writer as a VarInt.
§Errors
Returns a CodecError if the underlying writer fails. The error’s
byte count reports how much of this value was written successfully.
Sourcefn write_varint_with_size(&mut self, value: i32) -> Result<usize, CodecError>
fn write_varint_with_size(&mut self, value: i32) -> Result<usize, CodecError>
Writes value as a VarInt and returns the number of bytes written.
§Errors
Returns a CodecError if the underlying writer fails. The error’s
byte count reports how much of this value was written successfully.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".