[][src]Trait async_coap::send_desc::SendDesc

pub trait SendDesc<IC, R = (), TP = StandardCoapConstants>: Send where
    IC: InboundContext,
    R: Send,
    TP: TransParams, 
{ fn write_options(
        &self,
        msg: &mut dyn OptionInsert,
        socket_addr: &IC::SocketAddr,
        start: Bound<OptionNumber>,
        end: Bound<OptionNumber>
    ) -> Result<(), Error>;
fn write_payload(
        &self,
        msg: &mut dyn MessageWrite,
        socket_addr: &IC::SocketAddr
    ) -> Result<(), Error>;
fn handler(
        &mut self,
        context: Result<&IC, Error>
    ) -> Result<ResponseStatus<R>, Error>; fn trans_params(&self) -> Option<TP> { ... }
fn supports_option(&self, option: OptionNumber) -> bool { ... }
fn delay_to_retransmit(&self, retransmits_sent: u32) -> Option<Duration> { ... }
fn delay_to_restart(&self) -> Option<Duration> { ... }
fn max_rtt(&self) -> Duration { ... }
fn transmit_wait_duration(&self) -> Duration { ... } }

Send Descriptor Trait

Types implementing this trait can be passed to the send* methods of LocalEndpoint and RemoteEndpoint, and can define almost every aspect of how a message transaction is handled.

See the module level documentation for more information on typical usage patterns.

Internals

There are several methods in this trait, but three of them are critical:

  • write_options: Defines which options are going to be included in the outbound message.
  • write_payload: Defines the contents of the payload for the outbound message.
  • handler: Handles inbound reply messages, as well as error conditions.

Required methods

fn write_options(
    &self,
    msg: &mut dyn OptionInsert,
    socket_addr: &IC::SocketAddr,
    start: Bound<OptionNumber>,
    end: Bound<OptionNumber>
) -> Result<(), Error>

Defines which options are going to be included in the outbound message.

Writes all options in the given range to msg.

fn write_payload(
    &self,
    msg: &mut dyn MessageWrite,
    socket_addr: &IC::SocketAddr
) -> Result<(), Error>

Generates the outbound message by making calls into msg.

fn handler(
    &mut self,
    context: Result<&IC, Error>
) -> Result<ResponseStatus<R>, Error>

Handles the response to the outbound message.

Loading content...

Provided methods

fn trans_params(&self) -> Option<TP>

Experimental: Gets custom transmission parameters.

fn supports_option(&self, option: OptionNumber) -> bool

Experimental: Used for determining if the given option seen in the reply message is supported or not.

Response messages with any options that cause this method to return false will be rejected.

fn delay_to_retransmit(&self, retransmits_sent: u32) -> Option<Duration>

Calculates the duration of the delay to wait before sending the next retransmission.

If None is returned, then no further retransmissions will be attempted.

fn delay_to_restart(&self) -> Option<Duration>

The delay to wait between when we have received a successful response and when we should send out another request.

The new request will have a new msg_id, but the same token. The retransmission counter will be reset to zero.

This mechanism is currently used exclusively for CoAP observing.

The default return value is None, indicating that there are to be no message restarts.

fn max_rtt(&self) -> Duration

The maximum time to wait for an asynchronous response after having received an ACK.

fn transmit_wait_duration(&self) -> Duration

the maximum time from the first transmission of a Confirmable message to the time when the sender gives up on receiving an acknowledgement or reset.

Loading content...

Implementors

Loading content...