pub trait SendDescExt<IC, R, TP>: SendDesc<IC, R, TP> + Sizedwhere
IC: InboundContext,
R: Send,
TP: TransParams,{
// Provided methods
fn add_option_iter<K, I>(
self,
key: OptionKey<K>,
viter: I,
) -> AddOption<Self, K, I, IC>
where I: IntoIterator<Item = K> + Send + Clone,
K: Send + Clone { ... }
fn add_option<K>(
self,
key: OptionKey<K>,
value: K,
) -> AddOption<Self, K, Once<K>, IC>
where K: Send + Clone { ... }
fn accept(
self,
accept: ContentFormat,
) -> AddOption<Self, ContentFormat, Once<ContentFormat>, IC> { ... }
fn content_format(
self,
content_format: ContentFormat,
) -> AddOption<Self, ContentFormat, Once<ContentFormat>, IC> { ... }
fn use_handler<F, FR>(self, handler: F) -> Handler<Self, F>
where F: FnMut(Result<&dyn InboundContext<SocketAddr = IC::SocketAddr>, Error>) -> Result<ResponseStatus<FR>, Error> + Send,
FR: Send { ... }
fn emit_any_response(self) -> EmitAnyResponse<Self> { ... }
fn emit_successful_response(self) -> EmitSuccessfulResponse<Self> { ... }
fn emit_msg_code(self) -> EmitMsgCode<Self> { ... }
fn include_socket_addr(self) -> IncludeSocketAddr<Self> { ... }
fn inspect<F>(self, inspect: F) -> Inspect<Self, F>
where F: FnMut(&dyn InboundContext<SocketAddr = IC::SocketAddr>) + Send { ... }
fn payload_writer<F>(self, writer: F) -> PayloadWriter<Self, F>
where F: Fn(&mut dyn MessageWrite) -> Result<(), Error> + Send { ... }
fn uri_host_path<T: Into<RelRefBuf>>(
self,
host: Option<String>,
uri_path: T,
) -> UriHostPath<Self, IC> { ... }
}
Expand description
Combinator extension trait for Send Descriptors.
Provided Methods§
Sourcefn add_option_iter<K, I>(
self,
key: OptionKey<K>,
viter: I,
) -> AddOption<Self, K, I, IC>
fn add_option_iter<K, I>( self, key: OptionKey<K>, viter: I, ) -> AddOption<Self, K, I, IC>
Adds zero or more instances of the option key
, using values coming from viter
.
This method allows you to conditionally add options to a send descriptor. For example,
you could convert an Option
to an iterator (using into_iterator()
) and pass it to
this method: if the Option
is None
then no coap option will be added.
Sourcefn add_option<K>(
self,
key: OptionKey<K>,
value: K,
) -> AddOption<Self, K, Once<K>, IC>
fn add_option<K>( self, key: OptionKey<K>, value: K, ) -> AddOption<Self, K, Once<K>, IC>
Adds one instance of the option key
with a value of value
.
Sourcefn accept(
self,
accept: ContentFormat,
) -> AddOption<Self, ContentFormat, Once<ContentFormat>, IC>
fn accept( self, accept: ContentFormat, ) -> AddOption<Self, ContentFormat, Once<ContentFormat>, IC>
Adds an Accept option with the given ContentFormat
.
Sourcefn content_format(
self,
content_format: ContentFormat,
) -> AddOption<Self, ContentFormat, Once<ContentFormat>, IC>
fn content_format( self, content_format: ContentFormat, ) -> AddOption<Self, ContentFormat, Once<ContentFormat>, IC>
Adds an Content-Format option with the given ContentFormat
.
Sourcefn use_handler<F, FR>(self, handler: F) -> Handler<Self, F>where
F: FnMut(Result<&dyn InboundContext<SocketAddr = IC::SocketAddr>, Error>) -> Result<ResponseStatus<FR>, Error> + Send,
FR: Send,
fn use_handler<F, FR>(self, handler: F) -> Handler<Self, F>where
F: FnMut(Result<&dyn InboundContext<SocketAddr = IC::SocketAddr>, Error>) -> Result<ResponseStatus<FR>, Error> + Send,
FR: Send,
Adds a handler function to be called when a response message has been received (or when an error has occurred).
Sourcefn emit_any_response(self) -> EmitAnyResponse<Self>
fn emit_any_response(self) -> EmitAnyResponse<Self>
Updates the send descriptor chain to emit any received message as a result, even if that message has a message code that indicates an error.
Sourcefn emit_successful_response(self) -> EmitSuccessfulResponse<Self>
fn emit_successful_response(self) -> EmitSuccessfulResponse<Self>
Updates the send descriptor chain to emit received message as a result, but only if that message has a message code that indicates success.
Sourcefn emit_msg_code(self) -> EmitMsgCode<Self>
fn emit_msg_code(self) -> EmitMsgCode<Self>
Updates the send descriptor chain to emit only the message code of the received response.
Sourcefn include_socket_addr(self) -> IncludeSocketAddr<Self>
fn include_socket_addr(self) -> IncludeSocketAddr<Self>
Updates the send descriptor chain to also emit the SocketAddr of the sender of the response, resulting in tuple return type.
This is useful for handling responses to a multicast request.
Sourcefn inspect<F>(self, inspect: F) -> Inspect<Self, F>
fn inspect<F>(self, inspect: F) -> Inspect<Self, F>
Adds an inspection closure that will be called for each received response message.
The inspector closure will not be called if no responses are received, and it cannot
change the behavior of the send descriptor chain. If you need either of those
behaviors, see SendDescExt::use_handler
.
Sourcefn payload_writer<F>(self, writer: F) -> PayloadWriter<Self, F>
fn payload_writer<F>(self, writer: F) -> PayloadWriter<Self, F>
Adds a closure that writes to the payload of the outbound message.
Sourcefn uri_host_path<T: Into<RelRefBuf>>(
self,
host: Option<String>,
uri_path: T,
) -> UriHostPath<Self, IC>
fn uri_host_path<T: Into<RelRefBuf>>( self, host: Option<String>, uri_path: T, ) -> UriHostPath<Self, IC>
Allows you to specify the URI_HOST, URI_PATH, and URI_QUERY option values
in a more convenient way than using add_option_iter
manually.
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.
Implementors§
impl<T, IC, R, TP> SendDescExt<IC, R, TP> for T
Blanket implementation of SendDescExt
for all types implementing SendDesc
.