pub struct BlockAssembler { /* private fields */ }Expand description
Reassembles Block1 fragments into a complete request payload.
RFC 7959 §2.5: The server collects Block1 fragments from the client, validating sequential block numbers and consistent SZX values. Once the final block (M=0) arrives, the full payload is returned.
Implementations§
Source§impl BlockAssembler
impl BlockAssembler
Sourcepub fn new(max_payload: usize) -> Self
pub fn new(max_payload: usize) -> Self
Creates a new assembler with default block size and the given payload limit.
§Arguments
max_payload- Maximum total payload size after reassembly. Prevents resource exhaustion from unbounded block sequences.
Sourcepub fn process_block(
&mut self,
block: &BlockOption,
data: &[u8],
) -> CoapResult<bool>
pub fn process_block( &mut self, block: &BlockOption, data: &[u8], ) -> CoapResult<bool>
Processes an incoming Block1 fragment.
Validates that blocks arrive in order and that the reassembled payload does not exceed the configured maximum size.
Returns true when the final block has been received and the full
payload is available via payload().
Sourcepub fn payload(&self) -> Option<&[u8]>
pub fn payload(&self) -> Option<&[u8]>
Returns the reassembled payload, or None if transfer is incomplete.
Sourcepub fn into_payload(self) -> CoapResult<Vec<u8>>
pub fn into_payload(self) -> CoapResult<Vec<u8>>
Consumes the assembler and returns the reassembled payload.
Returns Err if the transfer is not yet complete.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Returns whether the final block has been received.