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§
source§impl AddAssign<BigSize> for BigSize
impl AddAssign<BigSize> for BigSize
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl DivAssign<BigSize> for BigSize
impl DivAssign<BigSize> for BigSize
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/=
operation. Read moresource§impl LightningDecode for BigSize
impl LightningDecode for BigSize
source§fn 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.source§fn 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.source§impl LightningEncode for BigSize
impl LightningEncode for BigSize
source§fn 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.source§fn 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.source§impl MulAssign<BigSize> for BigSize
impl MulAssign<BigSize> for BigSize
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl Ord for BigSize
impl Ord for BigSize
source§impl PartialEq<BigSize> for BigSize
impl PartialEq<BigSize> for BigSize
source§impl PartialOrd<BigSize> for BigSize
impl PartialOrd<BigSize> for BigSize
1.0.0 · source§fn 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 moresource§impl SubAssign<BigSize> for BigSize
impl SubAssign<BigSize> for BigSize
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moresource§impl Wrapper for BigSize
impl Wrapper for BigSize
source§fn from_inner(inner: Self::Inner) -> Self
fn from_inner(inner: Self::Inner) -> Self
Instantiates wrapper type with the inner data
source§fn as_inner(&self) -> &Self::Inner
fn as_inner(&self) -> &Self::Inner
Returns reference to the inner representation for the wrapper type
source§fn 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
source§fn into_inner(self) -> Self::Inner
fn into_inner(self) -> Self::Inner
Unwraps the wrapper returning the inner type