pub struct BlockOption {
pub num: u32,
pub more: bool,
pub szx: u8,
}Expand description
A decoded Block1 or Block2 option value.
RFC 7959 §2.2: The option value encodes three fields in a variable-length unsigned integer:
- Bits 0-2: SZX (block size exponent)
- Bit 3: M (more blocks follow)
- Bits 4+: NUM (block number)
Fields§
§num: u32Block number (0-based).
more: boolWhether more blocks follow this one.
szx: u8Block size exponent: actual size = 2^(szx + 4).
Implementations§
Source§impl BlockOption
impl BlockOption
Sourcepub fn decode(value: u32) -> Self
pub fn decode(value: u32) -> Self
Decodes a Block option from its wire representation.
RFC 7959 §2.2: The option value is a variable-length unsigned integer with the three least significant bits encoding SZX, bit 3 encoding M, and the remaining upper bits encoding NUM.
Sourcepub fn encode(&self) -> u32
pub fn encode(&self) -> u32
Encodes this Block option to its wire representation.
RFC 7959 §2.2: Packs NUM, M, and SZX into a single unsigned integer.
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Returns the block size in bytes for this option’s SZX value.
Trait Implementations§
Source§impl Clone for BlockOption
impl Clone for BlockOption
Source§fn clone(&self) -> BlockOption
fn clone(&self) -> BlockOption
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BlockOption
impl Debug for BlockOption
Source§impl PartialEq for BlockOption
impl PartialEq for BlockOption
impl Copy for BlockOption
impl Eq for BlockOption
impl StructuralPartialEq for BlockOption
Auto Trait Implementations§
impl Freeze for BlockOption
impl RefUnwindSafe for BlockOption
impl Send for BlockOption
impl Sync for BlockOption
impl Unpin for BlockOption
impl UnsafeUnpin for BlockOption
impl UnwindSafe for BlockOption
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