OutgoingCommunication

Struct OutgoingCommunication 

Source
pub struct OutgoingCommunication<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize>
where CLOCK: Clock, UDP: UdpClientStack,
{ /* private fields */ }
Expand description

Outgoing communication path. Sends outgoing requests, pings and CoAP Observe notifications and handles retransmissions and timeouts automatically.

Implementations§

Source§

impl<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> OutgoingCommunication<'a, CLOCK, UDP, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
where CLOCK: Clock, UDP: UdpClientStack,

Source

pub fn new( clock: &'a CLOCK, transmission_parameters: TransmissionParameters, ) -> Self

Initializes the outgoing communication path in the [OutgoingState::Idle(false)] state so it is ready to send requests.

Source

pub fn state(&self) -> OutgoingState

Returns the current state of the OutgoingCommunication. Depending on the state, the user must take action to drive the state forward, see the documentation to the states in OutgoingState.

Source

pub fn reset(&mut self)

Resets the internal state machine

Source

pub fn response( &self, ) -> Result<EncodedMessage<'_>, Error<<UDP as UdpClientStack>::Error>>

Returns the last response which is the same that was returned in the Success event before. Therefore, usage of this method is only required if the response should be used later (the message from the Success event can probably not be stored due to lifetime requirements).

This method is only available in [Idle(true)] and will return Error::Forbidden otherwise.

Source

pub fn schedule_non( &mut self, code: RequestCode, options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>, payload: Option<&[u8]>, timeout: Duration, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>

Schedules a non-confirmable request to be sent

The message is constructed with the given details (message_type, code, options and payload). The timeout is used for an application-level timeout which is used if no further retransmissions are tried.

Source

pub fn schedule_con( &mut self, code: RequestCode, options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>, payload: Option<&[u8]>, timeout: Duration, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>

Schedules a confirmable request to be sent

The timeout is used for an application-level timeout which is started as soon as an ACK is received (in case of piggybacked responses, we succeed immediately, so the timeout is not needed).

Source

pub fn schedule_notification( &mut self, confirmable: bool, code: ResponseCode, token: Token, options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>, payload: Option<&[u8]>, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>

Schedules a CoAP observe notification to be sent

The options must already contain the Observe option because the sequence number can not be determined in this method.

Source

pub fn schedule_ping( &mut self, timeout: Duration, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>

Schedules a ping to be sent

Source

pub fn cancel(&mut self) -> Result<(), Error<<UDP as UdpClientStack>::Error>>

Cancels the currently ongoing outgoing communication

This brings us back into the [OutgoingState::Idle(false)] state. Also, this sets up message de-duplication normally. This has the effect that if we receive a CON response for a cancelled request, an ACK will be automatically sent. This may look surprising but:

  1. this behavior is the same as normally receiving+acknowledging the response and just ignoring the response afterwards (which would be valid) and
  2. this enables the other endpoint to stop retransmitting its CON response.

If the currently ongoing communication is a notification, we will additionally be able to recognize corresponding RST messages and generate OutgoingEvent::NotificationRst events.

This method is available in all states but the Idle state. If in Idle state, it returns Error::Forbidden.

Source

pub fn parse_options<'options>( &self, url: &'options str, additional_options: Vec<CoapOption<'options>, MAX_OPTION_COUNT>, ) -> Result<Vec<CoapOption<'options>, MAX_OPTION_COUNT>, Error<<UDP as UdpClientStack>::Error>>

Associated helper method to easily create the appropriate request options from an Uri

Takes the request url and a list of additional options. The url is parsed into UriPaths and UriQuerys and merged with the additional options.

Trait Implementations§

Source§

impl<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> Debug for OutgoingCommunication<'a, CLOCK, UDP, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
where CLOCK: Clock + Debug, UDP: UdpClientStack + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> Freeze for OutgoingCommunication<'a, CLOCK, UDP, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>

§

impl<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> RefUnwindSafe for OutgoingCommunication<'a, CLOCK, UDP, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
where CLOCK: RefUnwindSafe, UDP: RefUnwindSafe,

§

impl<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> Send for OutgoingCommunication<'a, CLOCK, UDP, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
where CLOCK: Sync, UDP: Send,

§

impl<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> Sync for OutgoingCommunication<'a, CLOCK, UDP, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
where CLOCK: Sync, UDP: Sync,

§

impl<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> Unpin for OutgoingCommunication<'a, CLOCK, UDP, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
where UDP: Unpin,

§

impl<'a, CLOCK, UDP, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> UnwindSafe for OutgoingCommunication<'a, CLOCK, UDP, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
where CLOCK: RefUnwindSafe, UDP: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.