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>

source

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.

source

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.

source

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.

Auto Trait Implementations§

§

impl<Endpoint> Freeze for BlockHandler<Endpoint>

§

impl<Endpoint> RefUnwindSafe for BlockHandler<Endpoint>
where Endpoint: RefUnwindSafe,

§

impl<Endpoint> Send for BlockHandler<Endpoint>
where Endpoint: Send,

§

impl<Endpoint> Sync for BlockHandler<Endpoint>
where Endpoint: Sync,

§

impl<Endpoint> Unpin for BlockHandler<Endpoint>
where Endpoint: Unpin,

§

impl<Endpoint> UnwindSafe for BlockHandler<Endpoint>
where Endpoint: RefUnwindSafe + UnwindSafe,

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

§

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

§

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.