pub struct VarInt(_);
Expand description

The Variable Byte Integer is encoded using an encoding scheme which uses a single byte for values up to 127.

Larger values are handled as follows. The least significant seven bits of each byte encode the data, and the most significant bit is used to indicate whether there are bytes following in the representation. Thus, each byte encodes 128 values and a “continuation bit”. The maximum number of bytes in the Variable Byte Integer field is four. The encoded value MUST use the minimum number of bytes necessary to represent the value [MQTT-1.5.5-1].

Implementations

Returns an empty var int object.

Convert usize value into VarInt.

Errors

Returns error if len is too large.

Returns number of bytes of this var int object consums.

Returns true if var int is zero.

Returns integer value this var int object presents.

Add value v with current value.

Errors

Returns error if result is overflow.

Substract value v from current value.

Errors

Returns error if result is underflow.

Returns number of bytes of this var int object consums.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Decode byte array into a mqtt packet. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Encode packets into byte array. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.