Struct DatagramLocalEndpoint

Source
pub struct DatagramLocalEndpoint<US: AsyncDatagramSocket>
where Self: Send + Sync,
{ /* private fields */ }
Expand description

Generic, datagram-based CoAP local endpoint implementation.

Implementations§

Source§

impl<US: AsyncDatagramSocket> DatagramLocalEndpoint<US>

Source

pub fn new(socket: US) -> DatagramLocalEndpoint<US>

Creates a new DatagramLocalEndpoint instance with the given AsyncDatagramSocket and the standard scheme (coap:) and default port (5683).

Source

pub fn with_scheme_and_port( socket: US, scheme: &'static str, default_port: u16, ) -> DatagramLocalEndpoint<US>

Creates a new DatagramLocalEndpoint instance with the given AsyncDatagramSocket, using the specified scheme and default port.

Source

pub fn socket(&self) -> &US

Borrows a reference to the underlying socket.

Trait Implementations§

Source§

impl<US: Debug + AsyncDatagramSocket> Debug for DatagramLocalEndpoint<US>
where Self: Send + Sync,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<US: AsyncDatagramSocket> LocalEndpoint for DatagramLocalEndpoint<US>

Source§

type SocketAddr = <US as DatagramSocketTypes>::SocketAddr

The SocketAddr type to use with this local endpoint. This is usually simply std::net::SocketAddr, but may be different in some cases (like for CoAP-SMS endpoints).
Source§

type SocketError = <US as DatagramSocketTypes>::Error

The error type associated with errors generated by socket and address-lookup operations. Typically, this is std::io::Error, but it may be different if Self::SocketAddr isn’t std::net::SocketAddr.
Source§

type DefaultTransParams = StandardCoapConstants

The trait representing the default transmission parameters to use.
Source§

type LookupStream = Iter<IntoIter<<DatagramLocalEndpoint<US> as LocalEndpoint>::SocketAddr>>

The concrete return type of the lookup() method.
Source§

type RespondableInboundContext = DatagramRespondableInboundContext<<DatagramLocalEndpoint<US> as LocalEndpoint>::SocketAddr>

Type used by closure that is passed into receive(), representing the context for inbound requests.
Source§

type InboundContext = DatagramRespondableInboundContext<<DatagramLocalEndpoint<US> as LocalEndpoint>::SocketAddr>

Type used by closure that is passed into send(), representing the context for the response.
Source§

type RemoteEndpoint = DatagramRemoteEndpoint<US>

The concrete type for a RemoteEndpoint associated with this local endpoint.
Source§

fn remote_endpoint<S, H, P>( &self, addr: S, host: Option<H>, path: P, ) -> Self::RemoteEndpoint
where S: ToSocketAddrs<SocketAddr = Self::SocketAddr, Error = Self::SocketError>, H: Into<String>, P: Into<RelRefBuf>,

Constructs a new RemoteEndpoint instance for the given address, host, and path.
Source§

fn remote_endpoint_from_uri( &self, uri: &Uri, ) -> Result<Self::RemoteEndpoint, Error>

Constructs a new RemoteEndpoint instance for the given Uri.
Source§

fn send<'a, S, R, SD>( &'a self, dest: S, send_desc: SD, ) -> BoxFuture<'a, Result<R, Error>>
where S: ToSocketAddrs<SocketAddr = Self::SocketAddr, Error = Self::SocketError> + 'a, SD: SendDesc<Self::InboundContext, R> + 'a, R: Send + 'a,

Sends a message to remote_addr based on the criteria provided by send_desc. Read more
Source§

fn receive<'a, F>(&'a self, handler: F) -> BoxFuture<'a, Result<(), Error>>
where F: FnMut(&Self::RespondableInboundContext) -> Result<(), Error> + 'a + Send,

Receives a single request and runs the given handler on it once. Read more
Source§

fn scheme(&self) -> &'static str

Returns a string representing the scheme of the underlying transport. For example, this could return "coap", "coaps+sms", etc.
Source§

fn default_port(&self) -> u16

Returns the default port to use when the port is unspecified. This value is typically defined by the scheme. Returns zero if port numbers are ignored by the underlying technology.
Source§

fn lookup(&self, hostname: &str, port: u16) -> Result<Self::LookupStream, Error>

Method for asynchronously looking up the Self::SocketAddr instances for the given hostname and port.

Auto Trait Implementations§

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> LocalEndpointExt for T
where T: LocalEndpoint,

Source§

fn send_as_stream<'a, S, R, SD>( &'a self, dest: S, send_desc: SD, ) -> SendAsStream<'a, R>
where S: ToSocketAddrs<SocketAddr = Self::SocketAddr, Error = Self::SocketError> + 'a, SD: SendDesc<Self::InboundContext, R> + 'a, R: Send + 'a,

Sends a message where multiple responses are expected, returned as a SendAsStream. Read more
Source§

fn receive_as_stream<'a, F>( &'a self, handler: F, ) -> ReceiveAsStream<'a, Self, F>
where F: FnMut(&Self::RespondableInboundContext) -> Result<(), Error> + 'a + Clone + Unpin + Send,

Version of LocalEndpoint::receive that handles more than one inbound message, returning a crate::ReceiveAsStream instead of a future. Read more
Source§

fn receive_loop<'a, F>( &'a self, handler: F, ) -> Collect<ReceiveAsStream<'a, Self, F>, Error>
where F: FnMut(&Self::RespondableInboundContext) -> Result<(), Error> + 'a + Clone + Unpin + Send,

Convenience method for implementing a receive loop. Read more
Source§

fn receive_loop_arc<'a, F>( self: Arc<Self>, handler: F, ) -> ArcGuard<Self, Collect<ReceiveAsStream<'a, Self, F>, Error>>
where F: FnMut(&Self::RespondableInboundContext) -> Result<(), Error> + 'a + Clone + Send + Unpin, Self: 'a,

Version of LocalEndpointExt::receive_loop which consumes and holds an Arc<Self>. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V