Struct lightning_encoding::BigSize
source · [−]pub struct BigSize(_);
Expand description
Lightning TLV uses a custom variable-length integer called BigSize. It is similar to Bitcoin’s variable-length integers except that it is serialized in big-endian instead of little-endian.
BigSize specification is given at https://github.com/lightningnetwork/lightning-rfc/blob/master/01-messaging.md#type-length-value-format
Like Bitcoin’s variable-length integer, it exhibits ambiguity in that certain values can be encoded in several different ways, which we must check for at deserialization-time. Thus, if you’re looking for an example of a variable-length integer to use for your own project, move along, this is a rather poor design.
Implementations
Trait Implementations
sourceimpl AddAssign<BigSize> for BigSize
impl AddAssign<BigSize> for BigSize
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the +=
operation. Read more
sourceimpl BorrowMut<<BigSize as Wrapper>::Inner> for BigSize
impl BorrowMut<<BigSize as Wrapper>::Inner> for BigSize
sourcefn borrow_mut(&mut self) -> &mut <Self as Wrapper>::Inner
fn borrow_mut(&mut self) -> &mut <Self as Wrapper>::Inner
Mutably borrows from an owned value. Read more
sourceimpl DivAssign<BigSize> for BigSize
impl DivAssign<BigSize> for BigSize
sourcefn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the /=
operation. Read more
sourceimpl LightningDecode for BigSize
impl LightningDecode for BigSize
sourcefn lightning_decode<D: Read>(d: D) -> Result<Self, Error>
fn lightning_decode<D: Read>(d: D) -> Result<Self, Error>
Decode with the given std::io::Read
instance; must either
construct an instance or return implementation-specific error type. Read more
sourcefn lightning_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn lightning_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
Tries to deserialize byte array into the current type using
LightningDecode::lightning_decode
function. Read more
sourceimpl LightningEncode for BigSize
impl LightningEncode for BigSize
sourcefn lightning_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn lightning_encode<E: Write>(&self, e: E) -> Result<usize, Error>
Encode with the given std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type. Read more
sourcefn lightning_serialize(&self) -> Result<Vec<u8>, Error>
fn lightning_serialize(&self) -> Result<Vec<u8>, Error>
Serializes data as a byte array using
LightningEncode::lightning_encode
function. Read more
sourceimpl MulAssign<BigSize> for BigSize
impl MulAssign<BigSize> for BigSize
sourcefn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the *=
operation. Read more
sourceimpl Ord for BigSize
impl Ord for BigSize
sourceimpl PartialOrd<BigSize> for BigSize
impl PartialOrd<BigSize> for BigSize
sourcefn partial_cmp(&self, other: &BigSize) -> Option<Ordering>
fn partial_cmp(&self, other: &BigSize) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl SubAssign<BigSize> for BigSize
impl SubAssign<BigSize> for BigSize
sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the -=
operation. Read more
sourceimpl Wrapper for BigSize
impl Wrapper for BigSize
sourcefn from_inner(inner: Self::Inner) -> Self
fn from_inner(inner: Self::Inner) -> Self
Instantiates wrapper type with the inner data
sourcefn as_inner(&self) -> &Self::Inner
fn as_inner(&self) -> &Self::Inner
Returns reference to the inner representation for the wrapper type
sourcefn as_inner_mut(&mut self) -> &mut Self::Inner
fn as_inner_mut(&mut self) -> &mut Self::Inner
Returns a mutable reference to the inner representation for the wrapper type Read more
sourcefn into_inner(self) -> Self::Inner
fn into_inner(self) -> Self::Inner
Unwraps the wrapper returning the inner type
impl Copy for BigSize
impl Eq for BigSize
impl StructuralEq for BigSize
impl StructuralPartialEq for BigSize
Auto Trait Implementations
impl RefUnwindSafe for BigSize
impl Send for BigSize
impl Sync for BigSize
impl Unpin for BigSize
impl UnwindSafe for BigSize
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more