pub struct VarInt(pub u64);
Expand description
A variable-length unsigned integer.
Tuple Fields§
§0: u64
Implementations§
Source§impl VarInt
impl VarInt
pub const fn new(u: u64) -> Self
pub fn with(u: impl Into<usize>) -> Self
Sourcepub const fn len(&self) -> usize
pub const fn len(&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), and 9 otherwise.
pub const fn to_u64(&self) -> u64
pub const fn into_u64(self) -> u64
pub fn to_usize(&self) -> usize
pub fn into_usize(self) -> usize
Trait Implementations§
Source§impl ConsensusDecode for VarInt
impl ConsensusDecode for VarInt
fn consensus_decode( reader: &mut impl Read, ) -> Result<Self, ConsensusDecodeError>
fn consensus_deserialize( bytes: impl AsRef<[u8]>, ) -> Result<Self, ConsensusDecodeError>
Source§impl ConsensusEncode for VarInt
impl ConsensusEncode for VarInt
Source§impl Ord for VarInt
impl Ord for VarInt
Source§impl PartialOrd for VarInt
impl PartialOrd for VarInt
Source§impl StrictDecode for VarInt
impl StrictDecode for VarInt
fn strict_decode(reader: &mut impl TypedRead) -> Result<Self, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictEncode for VarInt
impl StrictEncode for VarInt
fn strict_encode<W: TypedWrite>(&self, writer: W) -> Result<W>
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictTuple for VarInt
impl StrictTuple for VarInt
const FIELD_COUNT: u8 = 1u8
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for VarInt
impl StrictType for VarInt
const STRICT_LIB_NAME: &'static str = LIB_NAME_BITCOIN
fn strict_name() -> Option<TypeName>
impl Copy for VarInt
impl Eq for VarInt
impl StrictProduct for VarInt
impl StructuralPartialEq for VarInt
Auto Trait Implementations§
impl Freeze for VarInt
impl RefUnwindSafe for VarInt
impl Send for VarInt
impl Sync for VarInt
impl Unpin for VarInt
impl UnwindSafe for VarInt
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.