Struct coap_lite::block_handler::BlockHandler
source · pub struct BlockHandler<Endpoint: Ord + Clone> { /* private fields */ }
Expand description
Implements block transfer by intercepting and caching requests and responses.
Implementations§
source§impl<Endpoint: Ord + Clone> BlockHandler<Endpoint>
impl<Endpoint: Ord + Clone> BlockHandler<Endpoint>
sourcepub fn new(config: BlockHandlerConfig) -> Self
pub fn new(config: BlockHandlerConfig) -> Self
Creates a new block handler which is expected to be re-used across all subsequent request/response pairs that may benefit from block handling.
sourcepub fn intercept_request(
&mut self,
request: &mut CoapRequest<Endpoint>
) -> Result<bool, HandlingError>
pub fn intercept_request( &mut self, request: &mut CoapRequest<Endpoint> ) -> Result<bool, HandlingError>
Intercepts request before application processing has occurred.
Returns true if the request requires Block1/2 handling and no further processing should occur (the response will be mutated inside the request and should be sent to the peer); false otherwise and handling should proceed to the application normally.
sourcepub fn intercept_response(
&mut self,
request: &mut CoapRequest<Endpoint>
) -> Result<bool, HandlingError>
pub fn intercept_response( &mut self, request: &mut CoapRequest<Endpoint> ) -> Result<bool, HandlingError>
Intercepts a prepared response before it is to be delivered over the
network. If the payload assigned to the response is too large to be
transmitted without fragmenting into blocks, the block handler will
cache the response and serve it out via subsequent client requests
(that in turn must be directed to BlockHandler::intercept_request
).
Returns true if the response has been manipulated and is being handled using Block1 or Block2 fragmentation; false otherwise.