pub struct VarLong(pub i64);Expand description
A variable-length two’s-complement signed 64-bit integer.
VarLongs use one to ten bytes on the wire. Each byte carries seven payload bits; the most-significant bit is set on every byte except the last.
§Examples
use mcproto_types::{TypeCodec, basic::VarLong};
let mut encoded = Vec::new();
VarLong(9_223_372_036_854_775_000).encode(&mut encoded)?;
let mut input = encoded.as_slice();
assert_eq!(
VarLong::decode(&mut input)?,
VarLong(9_223_372_036_854_775_000),
);
assert!(input.is_empty());Tuple Fields§
§0: i64The integer value.
Trait Implementations§
impl Copy for VarLong
Source§impl EnumRepr for VarLong
impl EnumRepr for VarLong
Source§fn from_discriminant(value: i128) -> Option<Self>
fn from_discriminant(value: i128) -> Option<Self>
Converts a Rust enum discriminant into this wire representation.
Source§fn discriminant(&self) -> i128
fn discriminant(&self) -> i128
Returns this representation as a numeric enum discriminant.
impl Eq for VarLong
impl StructuralPartialEq for VarLong
Auto Trait Implementations§
impl Freeze for VarLong
impl RefUnwindSafe for VarLong
impl Send for VarLong
impl Sync for VarLong
impl Unpin for VarLong
impl UnsafeUnpin for VarLong
impl UnwindSafe for VarLong
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ContextualCodec for Twhere
T: TypeCodec,
impl<T> ContextualCodec for Twhere
T: TypeCodec,
Source§fn encode_with_context(
&self,
writer: &mut impl Write,
_context: &Context,
) -> Result<(), CodecError>
fn encode_with_context( &self, writer: &mut impl Write, _context: &Context, ) -> Result<(), CodecError>
Encodes this value using context supplied by its enclosing structure.
Source§fn decode_with_context(
reader: &mut impl Read,
_context: &Context,
) -> Result<T, CodecError>where
T: Sized,
fn decode_with_context(
reader: &mut impl Read,
_context: &Context,
) -> Result<T, CodecError>where
T: Sized,
Decodes this value using context supplied by its enclosing structure.