[][src]Trait async_coap::send_desc::SendDescExt

pub trait SendDescExt<IC, R, TP>: SendDesc<IC, R, TP> + Sized where
    IC: InboundContext,
    R: Send,
    TP: TransParams, 
{ 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> { ... } }

Combinator extension trait for Send Descriptors.

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

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.

fn add_option<K>(
    self,
    key: OptionKey<K>,
    value: K
) -> AddOption<Self, K, Once<K>, IC> where
    K: Send + Clone

Adds one instance of the option key with a value of value.

fn accept(
    self,
    accept: ContentFormat
) -> AddOption<Self, ContentFormat, Once<ContentFormat>, IC>

Adds an Accept option with the given ContentFormat.

fn content_format(
    self,
    content_format: ContentFormat
) -> AddOption<Self, ContentFormat, Once<ContentFormat>, IC>

Adds an Content-Format option with the given ContentFormat.

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).

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.

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.

fn emit_msg_code(self) -> EmitMsgCode<Self>

Updates the send descriptor chain to emit only the message code of the received response.

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.

fn inspect<F>(self, inspect: F) -> Inspect<Self, F> where
    F: FnMut(&dyn InboundContext<SocketAddr = IC::SocketAddr>) + Send

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.

fn payload_writer<F>(self, writer: F) -> PayloadWriter<Self, F> where
    F: Fn(&mut dyn MessageWrite) -> Result<(), Error> + Send

Adds a closure that writes to the payload of the outbound message.

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.

Loading content...

Implementors

impl<T, IC, R, TP> SendDescExt<IC, R, TP> for T where
    T: SendDesc<IC, R, TP>,
    IC: InboundContext,
    R: Send,
    TP: TransParams, 
[src]

Blanket implementation of SendDescExt for all types implementing SendDesc.

Loading content...