IncomingCommunication

Struct IncomingCommunication 

Source
pub struct IncomingCommunication<'a, UDP: UdpClientStack, CLOCK: Clock, const BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }, const MAX_OPTION_COUNT: usize = { crate::DEFAULT_MAX_OPTION_COUNT }, const MAX_OPTION_SIZE: usize = { crate::DEFAULT_MAX_OPTION_SIZE }> { /* private fields */ }
Expand description

Incoming communication path. This handles incoming requests and pings which will be automatically answered with RST messages.

Implementations§

Source§

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

Source

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

Initializes the incoming communication path in the IncomingState::Idle state so it is ready to handle incoming requests.

Source

pub fn state(&self) -> IncomingState

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

Source

pub fn reset(&mut self)

Resets the internal state machine

Source

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

Returns the current request message which is the same that was returned in the Request event before. Therefore, usage of this method is only required if the decision between ACK + separate response and a piggybacked response shall be postponed (the message from the Request event can probably not be stored due to lifetime requirements).

This method is only available in IncomingState::Received, IncomingState::SendingAck and IncomingState::AwaitingResponse and will return Error::Forbidden otherwise.

Source

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

Schedules an immediate response to be sent.

If a confirmable request was received, a piggy-backed response will be scheduled. In case of a non-confirmable request, the response will be send as non-confirmable as well.

For more control, the user can check if the request was confirmable or non-confirmable themselves and call IncomingCommunication::schedule_empty_ack, IncomingCommunication::schedule_piggybacked_response, IncomingCommunication::schedule_con_response or IncomingCommunication::schedule_non_response accordingly.

Source

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

Schedules an Acknowledgement to be sent.

The ACK will fit the message_id for the last received request

Source

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

Schedules a RST message to be sent.

Source

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

Schedules an Acknowledgement with piggy-backed response

The ACK will fit the message_id for the last received request. The response is defined by the given details (code, payload and additional_options).

Source

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

Schedules a message to be sent as a separate CON response

Source

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

Schedules a message to be sent as a separate NON response

Trait Implementations§

Source§

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

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'a, UDP, CLOCK, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> UnwindSafe for IncomingCommunication<'a, UDP, CLOCK, 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.