Struct UnixDatagram
struct UnixDatagram { ... }
A Unix datagram socket.
Implementations
impl UnixDatagram
fn bind<P: AsRef<Path>>(path: P) -> Result<UnixDatagram>Creates a Unix datagram socket bound to the given path.
fn bind_addr(address: &SocketAddr) -> Result<UnixDatagram>Creates a new
UnixDatagrambound to the specified socketaddress.fn from_std(socket: UnixDatagram) -> UnixDatagramCreates a new
UnixDatagramfrom a standardnet::UnixDatagram.This function is intended to be used to wrap a Unix datagram from the standard library in the Mio equivalent. The conversion assumes nothing about the underlying datagram; it is left up to the user to set it in non-blocking mode.
fn connect<P: AsRef<Path>>(self: &Self, path: P) -> Result<()>Connects the socket to the specified address.
This may return a
WouldBlockin which case the socket connection cannot be completed immediately.fn unbound() -> Result<UnixDatagram>Creates a Unix Datagram socket which is not bound to any address.
fn pair() -> Result<(UnixDatagram, UnixDatagram)>Create an unnamed pair of connected sockets.
fn local_addr(self: &Self) -> Result<SocketAddr>Returns the address of this socket.
fn peer_addr(self: &Self) -> Result<SocketAddr>Returns the address of this socket's peer.
The
connectmethod will connect the socket to a peer.fn recv_from(self: &Self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>Receives data from the socket.
On success, returns the number of bytes read and the address from whence the data came.
fn recv(self: &Self, buf: &mut [u8]) -> Result<usize>Receives data from the socket.
On success, returns the number of bytes read.
fn send_to<P: AsRef<Path>>(self: &Self, buf: &[u8], path: P) -> Result<usize>Sends data on the socket to the specified address.
On success, returns the number of bytes written.
fn send(self: &Self, buf: &[u8]) -> Result<usize>Sends data on the socket to the socket's peer.
The peer address may be set by the
connectmethod, and this method will return an error if the socket has not already been connected.On success, returns the number of bytes written.
fn take_error(self: &Self) -> Result<Option<Error>>Returns the value of the
SO_ERRORoption.fn shutdown(self: &Self, how: Shutdown) -> Result<()>Shut down the read, write, or both halves of this connection.
This function will cause all pending and future I/O calls on the specified portions to immediately return with an appropriate value (see the documentation of
Shutdown).fn try_io<F, T>(self: &Self, f: F) -> Result<T> where F: FnOnce() -> Result<T>Execute an I/O operation ensuring that the socket receives more events if it hits a
WouldBlockerror.Notes
This method is required to be called for all I/O operations to ensure the user will receive events once the socket is ready again after returning a
WouldBlockerror.Examples
# use Error; # #
impl AsFd for UnixDatagram
fn as_fd(self: &Self) -> BorrowedFd<'_>
impl AsRawFd for UnixDatagram
fn as_raw_fd(self: &Self) -> RawFd
impl Debug for UnixDatagram
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Freeze for UnixDatagram
impl From for UnixDatagram
fn from(fd: OwnedFd) -> Self
impl FromRawFd for UnixDatagram
unsafe fn from_raw_fd(fd: RawFd) -> UnixDatagramConverts a
RawFdto aUnixDatagram.Notes
The caller is responsible for ensuring that the socket is in non-blocking mode.
impl IntoRawFd for UnixDatagram
fn into_raw_fd(self: Self) -> RawFd
impl RefUnwindSafe for UnixDatagram
impl Send for UnixDatagram
impl Source for UnixDatagram
fn register(self: &mut Self, registry: &Registry, token: Token, interests: Interest) -> Result<()>fn reregister(self: &mut Self, registry: &Registry, token: Token, interests: Interest) -> Result<()>fn deregister(self: &mut Self, registry: &Registry) -> Result<()>
impl Sync for UnixDatagram
impl Unpin for UnixDatagram
impl UnsafeUnpin for UnixDatagram
impl UnwindSafe for UnixDatagram
impl<T> Any for UnixDatagram
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for UnixDatagram
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for UnixDatagram
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for UnixDatagram
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for UnixDatagram
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for UnixDatagram
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for UnixDatagram
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>