[][src]Struct socket_collection::UdpSock

pub struct UdpSock { /* fields omitted */ }

Asynchronous UDP socket wrapper with some specific behavior to our use cases:

  • The maximum message length is as long as max UDP payload size.
  • Incoming/outgoing messages are buffered.
  • All messages are encrypted with EncryptContext and decrypted with DecryptContext that can be changed at any time.

Methods

impl UdpSock
[src]

Wrap UdpSocket and use the default socket configuration.

Wrap UdpSocket and use given socket configuration.

Create new UdpSock bound to the given address with default configuration.

Create new UdpSock bound to the given address with given configuration.

Specify data encryption context which will determine how outgoing data is encrypted.

Specify data decryption context which will determine how incoming data is decrypted.

Set default destination address for UDP socket.

Get the local address UDP socket is bound to.

Get the address UdpSock was connected to.

Set Time To Live value for the underlying UDP socket.

Retrieve Time To Live value.

Retrieve last socket error, if one exists.

Read message from the connected socket. Call this from inside the ready handler.

Returns:

  • Ok(Some(data)): data has been successfully read from the socket
  • Ok(None): there is not enough data in the socket. Call read() again in the next invocation of the ready handler.
  • Err(error): there was an error reading from the socket.

Read message from the socket. Call this from inside the ready handler.

Returns:

  • Ok(Some((data, peer_address))): data has been successfully read from the socket
  • Ok(None): there is not enough data in the socket. Call read() again in the next invocation of the ready handler.
  • Err(error): there was an error reading from the socket.

Write a message to the connected socket.

Returns:

  • Ok(true): the message has been successfully written.
  • Ok(false): the message has been queued, but not yet fully written. will be attempted in the next write schedule.
  • Err(error): there was an error while writing to the socket.

Write a message to the socket to the given address.

Returns:

  • Ok(true): the message has been successfully written.
  • Ok(false): the message has been queued, but not yet fully written. will be attempted in the next write schedule.
  • Err(error): there was an error while writing to the socket.

Retrieve the underlying mio UdpSocket.

Trait Implementations

impl From<UdpSock> for Socket
[src]

impl Default for UdpSock
[src]

impl Debug for UdpSock
[src]

impl Evented for UdpSock
[src]

Auto Trait Implementations

impl Send for UdpSock

impl Sync for UdpSock

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> UnsafeAny for T where
    T: Any

impl<T> Same for T

Should always be Self