Trait coap_request::Stack
source · pub trait Stack {
type RequestUnionError: Debug;
type RequestMessage<'a>: MinimalWritableMessage<UnionError = Self::RequestUnionError>
where Self: 'a;
type ResponseMessage<'a>: ReadableMessage
where Self: 'a;
type TransportError: Debug;
// Required method
fn request<Req: Request<Self>>(
&mut self,
request: Req
) -> impl Future<Output = Result<Req::Output, Self::TransportError>>;
}Expand description
The CoAP stack provided by a CoAP library
Acting on this requires an exclusive reference &mut self. Stacks that support multiple
concurrent requests can allow cloning the stack, or implement this on a shared reference
&self.
In its current form, this takes no “remote address” argument, nor arguments that indicate whether the request should be sent reliably. It is ecpected that stacks provide a builder like this:
let wkc = stack
.to("coap://example.com".parse().unwrap())
.reliably()
.request(GetWellKnownCore)
.awaitRequired Associated Types§
sourcetype RequestUnionError: Debug
type RequestUnionError: Debug
Directly accessible error type of the request messages
This is its own associated type because picking it from the RequestMessage would give it a lifetime, and things get complicated.
sourcetype RequestMessage<'a>: MinimalWritableMessage<UnionError = Self::RequestUnionError>
where
Self: 'a
type RequestMessage<'a>: MinimalWritableMessage<UnionError = Self::RequestUnionError> where Self: 'a
Type of message the client will write its request into
sourcetype ResponseMessage<'a>: ReadableMessage
where
Self: 'a
type ResponseMessage<'a>: ReadableMessage where Self: 'a
Type of message the client will read the response from
sourcetype TransportError: Debug
type TransportError: Debug
Error indicating an error at some point below the CoAP request-reponse mechanism
This can for example be a failure to establish a connection, or an invalid message from the
peer. Few transports may use an infallible type here: While they may do ample checks at
.to() time (eg. already starting a connection), any protocol error may wind up here. (A
notable exception is a Rust typed CoAP loopback device).