pub struct WireVarInt(/* private fields */);Expand description
Variable sized integer Protobuf wire value used to
encode the Protobuf types int32, int64, uint32,
uint64, sint32, sint64, bool and enum.
Implementations§
Source§impl WireVarInt
impl WireVarInt
pub fn from_raw(raw_value: u64) -> WireVarInt
Sourcepub fn from_bool(value: bool) -> WireVarInt
pub fn from_bool(value: bool) -> WireVarInt
Encode the given bool as Protobuf bool.
Sourcepub fn from_uint32(value: u32) -> WireVarInt
pub fn from_uint32(value: u32) -> WireVarInt
Encode the given u32 as Protobuf uint32.
Sourcepub fn from_int32(value: i32) -> WireVarInt
pub fn from_int32(value: i32) -> WireVarInt
Encode the given i32 as Protobuf int32 (encodes using two’s complements).
Sourcepub fn from_sint32(value: i32) -> WireVarInt
pub fn from_sint32(value: i32) -> WireVarInt
Encode the given i32 as Protobuf sint32 (encodes using ZigZag).
Sourcepub fn from_uint64(value: u64) -> WireVarInt
pub fn from_uint64(value: u64) -> WireVarInt
Encode the given u64 as Protobuf uint64.
Sourcepub fn from_int64(value: i64) -> WireVarInt
pub fn from_int64(value: i64) -> WireVarInt
Encode the given i32 as Protobuf int64 (encodes using two’s complements).
Sourcepub fn from_sint64(value: i64) -> WireVarInt
pub fn from_sint64(value: i64) -> WireVarInt
Encode the given i64 as Protobuf sint64 (encodes using ZigZag).
Sourcepub fn raw(&self) -> u64
pub fn raw(&self) -> u64
Returns the underlying stored encoded value (same as Self::as_uint64).
Sourcepub fn try_as_bool(&self) -> Option<bool>
pub fn try_as_bool(&self) -> Option<bool>
Try to interpret the varint as a Protobuf bool.
If the varint contains any value other then 1 or 0
None is returned.
Sourcepub fn try_as_uint32(&self) -> Option<u32>
pub fn try_as_uint32(&self) -> Option<u32>
Try to interpret the varint as a Protobuf uint32.
If the varint contains a value that is bigger then 32 bits
None is returned instead.
Sourcepub fn try_as_int32(&self) -> Option<i32>
pub fn try_as_int32(&self) -> Option<i32>
Try to interpret the varint as a Protobuf int32 (encoded
using two’s complements).
If the varint contains a value that is bigger then 32 bits
None is returned instead.
Sourcepub fn try_as_sint32(&self) -> Option<i32>
pub fn try_as_sint32(&self) -> Option<i32>
Try to interpret the varint as a Protobuf sint32 (encoded
using ZigZag).
If the varint contains a value that is bigger then 32 bits
None is returned instead.
Sourcepub fn as_int64(&self) -> i64
pub fn as_int64(&self) -> i64
Interpret the varint as a Protobuf int64 (encoded
using two’s complements).
Sourcepub fn as_sint64(&self) -> i64
pub fn as_sint64(&self) -> i64
Interpret the varint as a Protobuf sint64 (encoded
using ZigZag).
Sourcepub fn tag_byte_len(field_number: FieldNumber) -> i32
pub fn tag_byte_len(field_number: FieldNumber) -> i32
Returns the byte len of a encoded “tag” with the passed field number.
Tag is the value written before a message field value is written.
Sourcepub fn int32_byte_len(value: i32) -> i32
pub fn int32_byte_len(value: i32) -> i32
Returns the encoded byte len of a “int32” encoded as varint (encoded using two’s complements).
Sourcepub fn int64_byte_len(value: i64) -> i32
pub fn int64_byte_len(value: i64) -> i32
Returns the encoded byte len of a “int64” encoded as varint (encoded using two’s complements).
Sourcepub fn uint32_byte_len(value: u32) -> i32
pub fn uint32_byte_len(value: u32) -> i32
Returns the encoded byte len of a “uint32” encoded as varint.
Sourcepub fn uint64_byte_len(value: u64) -> i32
pub fn uint64_byte_len(value: u64) -> i32
Returns the encoded byte len of a “uint64” encoded as varint.
Sourcepub fn sint32_byte_len(value: i32) -> i32
pub fn sint32_byte_len(value: i32) -> i32
Returns the encoded byte len of a “sint32” encoded as varint (encoded using zig zag).
Sourcepub fn sint64_byte_len(value: i64) -> i32
pub fn sint64_byte_len(value: i64) -> i32
Returns the encoded byte len of a “sint64” encoded as varint (encoded using zig zag).
Trait Implementations§
Source§impl Clone for WireVarInt
impl Clone for WireVarInt
Source§fn clone(&self) -> WireVarInt
fn clone(&self) -> WireVarInt
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more