CoapEndpoint

Struct CoapEndpoint 

Source
pub struct CoapEndpoint<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize = { crate::DEFAULT_MAX_OPTION_COUNT }, const MAX_OPTION_SIZE: usize = { crate::DEFAULT_MAX_OPTION_SIZE }, const INCOMING_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }, const OUTGOING_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }, const RECEIVE_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }>
where UDP: UdpClientStack, RNG: Read, CLOCK: Clock,
{ /* private fields */ }
Expand description

Endpoint for 1-to-1 connection to another CoAP Endpoint

Implementations§

Source§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
where UDP: UdpClientStack, RNG: Read, CLOCK: Clock,

Source

pub fn connect_with_socket( &mut self, socket: UDP::UdpSocket, addr: SocketAddr, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>

Stores an already initialized socket inside the CoAP Endpoint.

This socket has to already be connected to a remote endpoint.

Source

pub fn connect_to_addr<'client>( &mut self, client: &'client mut UDP, addr: SocketAddr, ) -> Result<&'client mut UDP, Error<<UDP as UdpClientStack>::Error>>

Connects the CoAP Endpoint to a socket address and stores the socket.

Source

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

Closes the connection specified by the CoAP Endpoints socket.

Source§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
where UDP: UdpClientStack + Dns, RNG: Read, CLOCK: Clock,

Source

pub fn connect_to_url( &mut self, client: &mut UDP, url: &str, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>

Connect the Endpoint to the specified URL string.

The URL has to have the format coap://<host>:<port>, although the port is optional. If you specify a hostname, a DNS lookup will be made. If you specify an IP Address, no lookup has to be done.

Source§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
where UDP: UdpClientStack, RNG: Read, CLOCK: Clock,

Source

pub fn try_new( transmission_parameters: TransmissionParameters, rng: RNG, clock: &'a CLOCK, receive_buffer: &'a mut [u8], ) -> Result<Self, Error<<UDP as UdpClientStack>::Error>>

Constructs a new CoAP Endpoint.

Initializes the message_id_counter randomly.

Source

pub fn incoming( &mut self, ) -> &mut IncomingCommunication<'a, UDP, CLOCK, INCOMING_BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>

Source

pub fn outgoing( &mut self, ) -> &mut OutgoingCommunication<'a, CLOCK, UDP, OUTGOING_BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>

Source

pub fn process( &mut self, client_stack: &mut UDP, ) -> Result<(Result<IncomingEvent<'_>, Error<<UDP as UdpClientStack>::Error>>, Result<OutgoingEvent<'_>, Error<<UDP as UdpClientStack>::Error>>, EndpointEvent<'_>), Error<<UDP as UdpClientStack>::Error>>

Handles internal state machine.

Has to be called periodically. If any ongoing process is present, this function has to be called at an interval less than CoapEndpoint::transmission_parameter.ack_timeout.

This method receives a possibly pending RX message and offers this received message to IncomingCommunication and OutgoingCommunication. Incoming pings are automatically answered with a RST message and a corresponding EndpointEvent::Ping is generated. If neither the incoming nor the outgoing communication path have consumed the RX message, an EndpointEvent::Unhandled is generated.

Unhandled requests are silently ignored because we may be able to handle a possible future retransmission. Unhandled NON and CON responses are automatically rejected with a RST message because there is no reason to believe that a response which was not consumed now will be handled in the future. Unhandled ACKs and RSTs are silently ignored because there must never be a response to ACKs and RSTs, see section 4.2. (Messages Transmitted Reliably) from RFC 7252: “More generally, recipients of Acknowledgement and Reset messages MUST NOT respond with either Acknowledgement or Reset messages.”

Trait Implementations§

Source§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> Debug for CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
where UDP: UdpClientStack + Debug, RNG: Read + Debug, CLOCK: Clock + Debug, UDP::UdpSocket: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> Freeze for CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
where RNG: Freeze, <UDP as UdpClientStack>::UdpSocket: Freeze,

§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> RefUnwindSafe for CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>

§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> Send for CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
where RNG: Send, <UDP as UdpClientStack>::UdpSocket: Send, CLOCK: Sync, UDP: Send,

§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> Sync for CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
where RNG: Sync, <UDP as UdpClientStack>::UdpSocket: Sync, CLOCK: Sync, UDP: Sync,

§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> Unpin for CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
where RNG: Unpin, <UDP as UdpClientStack>::UdpSocket: Unpin, UDP: Unpin,

§

impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize = { crate::DEFAULT_MAX_OPTION_COUNT }, const MAX_OPTION_SIZE: usize = { crate::DEFAULT_MAX_OPTION_SIZE }, const INCOMING_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }, const OUTGOING_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }, const RECEIVE_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }> !UnwindSafe for CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>

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.