Trait coap_handler::Handler
source · pub trait Handler {
type RequestData;
// Required methods
fn extract_request_data(
&mut self,
request: &impl ReadableMessage
) -> Self::RequestData;
fn estimate_length(&mut self, request: &Self::RequestData) -> usize;
fn build_response(
&mut self,
response: &mut impl MutableWritableMessage,
request: Self::RequestData
);
}
Expand description
A CoAP request handler. This gets called by a CoAP server implementation that the handler is assigned to; the server has the handler digest the request’s data into a RequestData structure, possibly calls estimate_length before allocating a response message, and then asks the handler to populate the allocated response message with data persisted in the RequestData structure.
Required Associated Types§
type RequestData
Required Methods§
fn extract_request_data( &mut self, request: &impl ReadableMessage ) -> Self::RequestData
fn estimate_length(&mut self, request: &Self::RequestData) -> usize
fn build_response( &mut self, response: &mut impl MutableWritableMessage, request: Self::RequestData )
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl<H> Handler for Option<H>where
H: Handler,
impl<H> Handler for Option<H>where
H: Handler,
An easy way to have resources that may or may not be there in a tree, considering that Handler
is not object safe and thus, if let Some(x) { all = all.at(...)
won’t work.
This returns 4.04 Not Found if the inner handler is absent, and otherwise forwards request and response building.