pub struct VarInt(pub u64);Expand description
A Bitcoin protocol variable-length integer.
VarInt is used in transaction data to indicate the number of upcoming fields or the length of an upcoming field. The encoding uses 1, 3, 5, or 9 bytes depending on the magnitude of the value.
Tuple Fields§
§0: u64Implementations§
Source§impl VarInt
impl VarInt
Sourcepub fn from_bytes(data: &[u8]) -> Result<(Self, usize), PrimitivesError>
pub fn from_bytes(data: &[u8]) -> Result<(Self, usize), PrimitivesError>
Sourcepub fn upper_limit_inc(&self) -> i32
pub fn upper_limit_inc(&self) -> i32
Check if this value is at the upper boundary of a VarInt size class.
Returns how many extra bytes would be needed if the value were
incremented by 1. Returns -1 at u64::MAX (cannot increment).
§Returns
0 if not at a boundary, 2 or 4 for size-class transitions, -1 at max.
Trait Implementations§
impl Copy for VarInt
impl Eq 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 UnsafeUnpin 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