VarInt

Enum VarInt 

Source
pub enum VarInt {
    U8(u8),
    U16(u16),
    U32(u32),
    U64(u64),
}
Expand description

Enum representing a Bitcoin variable-length integer

Variants§

§

U8(u8)

u8 that’s [..=0xFC]

§

U16(u16)

u16 that’s [0xFD..=0xFFFF]

§

U32(u32)

u32 that’s [0x10000..=0xFFFFFFFF]

§

U64(u64)

u64 that’s [0x100000000..=0xFFFFFFFFFFFFFFFF]

Implementations§

Source§

impl VarInt

Source

pub fn arrow_U8_0(self) -> u8

Source

pub fn arrow_U16_0(self) -> u16

Source

pub fn arrow_U32_0(self) -> u32

Source

pub fn arrow_U64_0(self) -> u64

Source§

impl VarInt

Source

pub open spec fn spec_as_usize(self) -> usize

{ self.spec_into() }

Spec version of VarInt::as_usize

Source

pub exec fn as_usize(self) -> o : usize

ensures
o@ == self.spec_as_usize(),

Converts a VarInt into a usize

Trait Implementations§

Source§

impl Clone for VarInt

Source§

fn clone(&self) -> VarInt

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VarInt

Source§

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

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

impl From<VarInt> for usize

Source§

exec fn ex_from(t: VarInt) -> usize

Source§

impl PartialEq for VarInt

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SpecFrom<VarInt> for usize

Source§

open spec fn spec_from(t: VarInt) -> usize

{
    match t {
        VarInt::U8(t) => t as usize,
        VarInt::U16(t) => t as usize,
        VarInt::U32(t) => t as usize,
        VarInt::U64(t) => t as usize,
    }
}
Source§

impl SpecTryFrom<(u8, Either<Seq<u8>, Either<u16, Either<u32, u64>>>)> for VarInt

Source§

open spec fn spec_try_from( t: (u8, Either<Seq<u8>, Either<u16, Either<u32, u64>>>), ) -> Result<Self, Self::Error>

{
    match t.1 {
        inj_ord_choice_pat!(x, *, *, *) => {
            if x == Seq::<u8>::empty() { Ok(VarInt::U8(t.0)) } else { Err(()) }
        }
        inj_ord_choice_pat!(*, x, *, *) => {
            if t.0 == SPEC_TAG_U16 { Ok(VarInt::U16(x)) } else { Err(()) }
        }
        inj_ord_choice_pat!(*, *, x, *) => {
            if t.0 == SPEC_TAG_U32 { Ok(VarInt::U32(x)) } else { Err(()) }
        }
        inj_ord_choice_pat!(*, *, *, x) => {
            if t.0 == SPEC_TAG_U64 { Ok(VarInt::U64(x)) } else { Err(()) }
        }
    }
}
Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

impl SpecTryFrom<VarInt> for (u8, Either<Seq<u8>, Either<u16, Either<u32, u64>>>)

Source§

open spec fn spec_try_from(t: VarInt) -> Result<Self, Self::Error>

{
    match t {
        VarInt::U8(t) => Ok((t, inj_ord_choice_result!(Seq::< u8 >::empty(), *, *, *))),
        VarInt::U16(x) => Ok((SPEC_TAG_U16, inj_ord_choice_result!(*, x, *, *))),
        VarInt::U32(x) => Ok((SPEC_TAG_U32, inj_ord_choice_result!(*, *, x, *))),
        VarInt::U64(x) => Ok((SPEC_TAG_U64, inj_ord_choice_result!(*, *, *, x))),
    }
}
Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

impl<'x> TryFrom<&'x VarInt> for (&'x u8, Either<&'x &'x [u8], Either<&'x u16, Either<&'x u32, &'x u64>>>)

Source§

exec fn ex_try_from(t: &'x VarInt) -> Result<Self, Self::Error>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

impl TryFrom<(u8, Either<&[u8], Either<u16, Either<u32, u64>>>)> for VarInt

Source§

exec fn ex_try_from( t: (u8, Either<&[u8], Either<u16, Either<u32, u64>>>), ) -> Result<Self, Self::Error>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

impl View for VarInt

Source§

open spec fn view(&self) -> Self::V

{ *self }
Source§

type V = VarInt

Source§

impl Copy for VarInt

Source§

impl Eq for VarInt

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T
where T: View, <T as View>::V: SpecFrom<<T as View>::V>,

Source§

exec fn ex_from(t: T) -> res : T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, VERUS_SPEC__A> FromSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: From<T>,

§

fn obeys_from_spec() -> bool

§

fn from_spec(v: T) -> VERUS_SPEC__A

Source§

impl<T, U> Into<U> for T
where T: View, U: View + From<T>, <U as View>::V: SpecFrom<<T as View>::V>,

Source§

exec fn ex_into(self) -> U

Source§

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

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.

§

impl<T, VERUS_SPEC__A> IntoSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: Into<T>,

§

fn obeys_into_spec() -> bool

§

fn into_spec(self) -> T

§

impl<T, U> IntoSpecImpl<U> for T
where U: From<T>,

§

fn obeys_into_spec() -> bool

§

fn into_spec(self) -> U

§

impl<A, Rhs> PartialEqIs<Rhs> for A
where A: PartialEq<Rhs> + ?Sized, Rhs: ?Sized,

§

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

§

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

§

impl<Rhs, VERUS_SPEC__A> PartialEqSpec<Rhs> for VERUS_SPEC__A
where VERUS_SPEC__A: PartialEq<Rhs> + ?Sized, Rhs: ?Sized,

§

fn obeys_eq_spec() -> bool

§

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

Source§

impl<T> SpecFrom<T> for T

Source§

open spec fn spec_from(t: T) -> T

{ t }
Source§

impl<T, U> SpecInto<U> for T
where U: SpecFrom<T>,

Source§

open spec fn spec_into(self) -> U

{ U::spec_from(self) }
Source§

impl<T, U> SpecTryInto<U> for T
where U: SpecTryFrom<T>,

Source§

open spec fn spec_try_into(self) -> Result<U, <U as SpecTryFrom<T>>::Error>

{ U::spec_try_from(self) }
Source§

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

The type returned in the event of a conversion error.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
§

impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: TryFrom<T>,

§

fn obeys_try_from_spec() -> bool

§

fn try_from_spec( v: T, ) -> Result<VERUS_SPEC__A, <VERUS_SPEC__A as TryFrom<T>>::Error>

Source§

impl<T, U> TryInto<U> for T
where T: View, U: View + TryFrom<T>, <U as View>::V: SpecTryFrom<<T as View>::V>,

Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
§

impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: TryInto<T>,

§

fn obeys_try_into_spec() -> bool

§

fn try_into_spec(self) -> Result<T, <VERUS_SPEC__A as TryInto<T>>::Error>

§

impl<T, U> TryIntoSpecImpl<U> for T
where U: TryFrom<T>,

§

fn obeys_try_into_spec() -> bool

§

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