pub struct CollectionLength(pub u64);Expand description
The lightning protocol uses u16s for lengths in most cases. As our serialization framework primarily targets that, we must as well. However, because we may serialize objects that have more than 65K entries, we need to be able to store larger values. Thus, we define a variable length integer here that is backwards-compatible for values < 0xffff. We treat 0xffff as “read eight more bytes”.
To ensure we only have one valid encoding per value, we add 0xffff to values written as eight bytes. Thus, 0xfffe is serialized as 0xfffe, whereas 0xffff is serialized as 0xffff0000000000000000 (i.e. read-eight-bytes then zero).
Tuple Fields§
§0: u64Trait Implementations§
Source§impl Readable for CollectionLength
impl Readable for CollectionLength
Source§impl Writeable for CollectionLength
impl Writeable for CollectionLength
Auto Trait Implementations§
impl Freeze for CollectionLength
impl RefUnwindSafe for CollectionLength
impl Send for CollectionLength
impl Sync for CollectionLength
impl Unpin for CollectionLength
impl UnwindSafe for CollectionLength
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> LengthReadable for Twhere
T: Readable,
impl<T> LengthReadable for Twhere
T: Readable,
Source§fn read_from_fixed_length_buffer<R>(reader: &mut R) -> Result<T, DecodeError>where
R: LengthLimitedRead,
fn read_from_fixed_length_buffer<R>(reader: &mut R) -> Result<T, DecodeError>where
R: LengthLimitedRead,
Reads a
Self in from the given LengthLimitedRead.