Trait SendDesc

Source
pub trait SendDesc<IC, R = (), TP = StandardCoapConstants>: Send
where IC: InboundContext, R: Send, TP: TransParams,
{ // Required methods 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>; // Provided methods 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 { ... } }
Expand description

§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§

Source

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.

Source

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

Generates the outbound message by making calls into msg.

Source

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

Handles the response to the outbound message.

Provided Methods§

Source

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

Experimental: Gets custom transmission parameters.

Source

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.

Source

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.

Source

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.

Source

fn max_rtt(&self) -> Duration

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

Source

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.

Implementors§

Source§

impl<'a, SD, IC, R, K, I> SendDesc<IC, R> for AddOption<SD, K, I, IC>
where SD: SendDesc<IC, R> + Send, IC: InboundContext, R: Send, I: IntoIterator<Item = K> + Clone + Send, K: Into<OptionValue<'a>>,

Source§

impl<IC> SendDesc<IC> for CoapRequestMethod<IC>
where IC: InboundContext,

Source§

impl<IC: InboundContext> SendDesc<IC> for Ping

Source§

impl<IC: InboundContext> SendDesc<IC> for SendDelete<IC>

Source§

impl<IC: InboundContext> SendDesc<IC> for SendGet<IC>

Source§

impl<IC: InboundContext> SendDesc<IC> for SendObserve<IC>

Source§

impl<IC: InboundContext> SendDesc<IC> for SendPost<IC>

Source§

impl<IC: InboundContext> SendDesc<IC> for SendPut<IC>

Source§

impl<SD, F, IC, R> SendDesc<IC, R> for Handler<SD, F>
where SD: SendDesc<IC, ()> + Send, IC: InboundContext, R: Send, F: FnMut(Result<&dyn InboundContext<SocketAddr = IC::SocketAddr>, Error>) -> Result<ResponseStatus<R>, Error> + Send,

Source§

impl<SD, F, IC, R> SendDesc<IC, R> for Inspect<SD, F>
where SD: SendDesc<IC, R> + Send, IC: InboundContext, R: Send, F: FnMut(&dyn InboundContext<SocketAddr = IC::SocketAddr>) + Send,

Source§

impl<SD, F, IC, R> SendDesc<IC, R> for PayloadWriter<SD, F>
where SD: SendDesc<IC, R> + Send, IC: InboundContext, R: Send, F: Fn(&mut dyn MessageWrite) -> Result<(), Error> + Send,

Source§

impl<SD, IC> SendDesc<IC> for Multicast<SD>
where SD: SendDesc<IC, ()> + Send, IC: InboundContext,

Source§

impl<SD, IC> SendDesc<IC> for Nonconfirmable<SD>
where SD: SendDesc<IC, ()> + Send, IC: InboundContext,

Source§

impl<SD, IC> SendDesc<IC, MsgCode> for EmitMsgCode<SD>
where SD: SendDesc<IC, ()> + Send, IC: InboundContext,

Source§

impl<SD, IC> SendDesc<IC, OwnedImmutableMessage> for EmitAnyResponse<SD>
where SD: SendDesc<IC, ()> + Send, IC: InboundContext,

Source§

impl<SD, IC> SendDesc<IC, OwnedImmutableMessage> for EmitSuccessfulResponse<SD>
where SD: SendDesc<IC, ()> + Send, IC: InboundContext,

Source§

impl<SD, IC> SendDesc<IC, OwnedImmutableMessage> for UnicastBlock2Collect<SD, IC>
where SD: SendDesc<IC, ()> + Send + SendDescUnicast, IC: InboundContext,

Source§

impl<SD, IC, R> SendDesc<IC, (R, <IC as InboundContext>::SocketAddr)> for IncludeSocketAddr<SD>
where SD: SendDesc<IC, R> + Send, IC: InboundContext, R: Send,

Source§

impl<SD, IC, R> SendDesc<IC, R> for UnicastBlock2<SD, IC>
where SD: SendDesc<IC, R> + Send + SendDescUnicast, IC: InboundContext, R: Send,

Source§

impl<SD, IC, R> SendDesc<IC, R> for UriHostPath<SD, IC>
where SD: SendDesc<IC, R>, IC: InboundContext, R: Send,