Struct darkfi_serial::VarInt

source ·
pub struct VarInt(pub u64);
Expand description

Variable-integer encoding

Tuple Fields§

§0: u64

Implementations§

source§

impl VarInt

source

pub fn length(&self) -> usize

Gets the length of this VarInt when encoded. Returns:

  • 1 for 0..0xFC
  • 3 for 0xFD..(2^16-1)
  • 5 for 0x10000..(2^32-1)
  • 9 otherwise

Trait Implementations§

source§

impl Debug for VarInt

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Decodable for VarInt

source§

fn decode<D: Read>(d: D) -> Result<Self, Error>

source§

impl Encodable for VarInt

source§

fn encode<S: Write>(&self, s: S) -> Result<usize, Error>

Encode an object with a well-defined format. Should only ever error if the underlying Write errors. Returns the number of bytes written on success.
source§

impl PartialEq<VarInt> for VarInt

source§

fn eq(&self, other: &VarInt) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for VarInt

source§

impl StructuralEq for VarInt

source§

impl StructuralPartialEq for VarInt

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.