Struct tokio_uds::UnixDatagram
[−]
[src]
pub struct UnixDatagram { /* fields omitted */ }
An I/O object representing a Unix datagram socket.
Methods
impl UnixDatagram
[src]
fn bind<P>(path: P, handle: &Handle) -> Result<UnixDatagram> where P: AsRef<Path>
Creates a new UnixDatagram
bound to the specified path.
fn pair(handle: &Handle) -> Result<(UnixDatagram, UnixDatagram)>
Creates an unnamed pair of connected sockets.
This function will create a pair of interconnected unix sockets for communicating back and forth between one another. Each socket will be associated with the event loop whose handle is also provided.
fn from_datagram(datagram: UnixDatagram,
handle: &Handle)
-> Result<UnixDatagram>
handle: &Handle)
-> Result<UnixDatagram>
Consumes a UnixDatagram
in the standard library and returns a
nonblocking UnixDatagram
from this crate.
The returned datagram will be associated with the given event loop
specified by handle
and is ready to perform I/O.
fn connect<P: AsRef<Path>>(&self, path: P) -> Result<()>
Connects the socket to the specified address.
The send
method may be used to send data to the specified address.
recv
and recv_from
will only receive data from that address.
fn poll_read(&self) -> Async<()>
Test whether this socket is ready to be read or not.
fn poll_write(&self) -> Async<()>
Test whether this socket is ready to be written to or not.
fn local_addr(&self) -> Result<SocketAddr>
Returns the local address that this socket is bound to.
fn peer_addr(&self) -> Result<SocketAddr>
Returns the address of this socket's peer.
The connect
method will connect the socket to a peer.
fn recv_from(&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, buf: &mut [u8]) -> Result<usize>
Receives data from the socket.
On success, returns the number of bytes read.
fn recv_dgram<T>(self, buf: T) -> RecvDgram<T> where T: AsMut<[u8]>
Returns a future for receiving a datagram. See the documentation on RecvDgram for details.
fn send_to<P>(&self, buf: &[u8], path: P) -> Result<usize> where P: AsRef<Path>
Sends data on the socket to the specified address.
On success, returns the number of bytes written.
fn send(&self, buf: &[u8]) -> Result<usize>
Sends data on the socket to the socket's peer.
The peer address may be set by the connect
method, and this method
will return an error if the socket has not already been connected.
On success, returns the number of bytes written.
fn send_dgram<T, P>(self, buf: T, path: P) -> SendDgram<T, P> where T: AsRef<[u8]>, P: AsRef<Path>
Returns a future sending the data in buf to the socket at path.
fn take_error(&self) -> Result<Option<Error>>
Returns the value of the SO_ERROR
option.
fn shutdown(&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 framed<C>(self, codec: C) -> UnixDatagramFramed<C> where C: UnixDatagramCodec
Provides a Stream
and Sink
interface for reading and writing to
this UnixDatagram
object, using the provided UnixDatagramCodec
to
read and write the raw data.
Raw UnixDatagram
sockets work with datagrams, but higher-level code
usually wants to batch these into meaningful chunks, called "frames".
This method layers framing on top of this socket by using the
UnixDatagramCodec
trait to handle encoding and decoding of messages
frames. Note that the incoming and outgoing frame types may be distinct.
This function returns a single object that is both Stream
and
Sink
; grouping this into a single object is often useful for layering
things which require both read and write access to the underlying
object.
If you want to work more directly with the streams and sink, consider
calling split
on the UnixDatagramFramed
returned by this method,
which will break them into separate objects, allowing them to interact
more easily.