Skip to main content

BlockDisassembler

Struct BlockDisassembler 

Source
pub struct BlockDisassembler { /* private fields */ }
Expand description

Splits a response payload into Block2 chunks for incremental delivery.

RFC 7959 §2.4: The server sends the first block proactively, then the client requests subsequent blocks by including a Block2 option with the desired block number.

Implementations§

Source§

impl BlockDisassembler

Source

pub fn new(payload: Vec<u8>, szx: u8) -> Self

Creates a new disassembler for the given payload and block size.

§Arguments
  • payload - Complete response payload to split into blocks.
  • szx - Block size exponent. Clamped to MAX_SZX.
Source

pub fn get_block(&self, block_num: u32) -> Option<(Vec<u8>, BlockOption)>

Returns the block data and corresponding Block2 option for the given block number.

Returns None if block_num is beyond the last block.

Source

pub fn total_blocks(&self) -> u32

Returns the total number of blocks required for this payload.

Source

pub fn payload_len(&self) -> usize

Returns the full payload length in bytes.

Source

pub fn szx(&self) -> u8

Returns the block size exponent.

Trait Implementations§

Source§

impl Debug for BlockDisassembler

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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.
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.