Trait coap_request::Request

source ·
pub trait Request<S: Stack + ?Sized> {
    type Output;
    type Carry;

    // Required methods
    fn build_request(
        &mut self,
        request: &mut S::RequestMessage<'_>
    ) -> impl Future<Output = Result<Self::Carry, S::RequestUnionError>>;
    fn process_response(
        &mut self,
        response: &S::ResponseMessage<'_>,
        carry: Self::Carry
    ) -> impl Future<Output = Self::Output>;
}
Expand description

Interface describing a CoAP request a client wants to send

This interface requires describes the request itself, and is passed to the stack in Stack::request.

Where possible, implementers should keep the [build_request] and [process_response] async functions short, ideally not having any await points at all. The interface is defined to allow slow interfaces to read into the buffer already allocated by the stack without blocking the remaining operations of the stack.

Required Associated Types§

Required Methods§

source

fn build_request( &mut self, request: &mut S::RequestMessage<'_> ) -> impl Future<Output = Result<Self::Carry, S::RequestUnionError>>

Build the request message

The stack may run this multiple times if it requires retransmissions. This function may produce different results, and the response handler must be prepared to process the response to any of the requests.

source

fn process_response( &mut self, response: &S::ResponseMessage<'_>, carry: Self::Carry ) -> impl Future<Output = Self::Output>

Process the response message

The stack calls this once, with any of the Carry produced by [build_request] (which as pointed out there does not indicate whether it was precisely that Carry’s request that is being responded to).

Object Safety§

This trait is not object safe.

Implementors§