pub trait Stack {
type RequestMessage<'a>: MinimalWritableMessage
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 RequestMessage<'a>: MinimalWritableMessage
where
Self: 'a
type RequestMessage<'a>: MinimalWritableMessage 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).
Required Methods§
fn request<Req: Request<Self>>( &mut self, request: Req, ) -> impl Future<Output = Result<Req::Output, Self::TransportError>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.