Struct tokio::net::UnixStream [−][src]
pub struct UnixStream { /* fields omitted */ }
Expand description
A structure representing a connected Unix socket.
This socket can be connected directly with UnixStream::connect
or accepted
from a listener with UnixListener::incoming
. Additionally, a pair of
anonymous Unix sockets can be created with UnixStream::pair
.
Implementations
impl UnixStream
[src]
impl UnixStream
[src]pub async fn connect<P>(path: P) -> Result<UnixStream> where
P: AsRef<Path>,
[src]
pub async fn connect<P>(path: P) -> Result<UnixStream> where
P: AsRef<Path>,
[src]Connects to the socket named by path
.
This function will create a new Unix socket and connect to the path specified, associating the returned stream with the default event loop’s handle.
pub fn from_std(stream: UnixStream) -> Result<UnixStream>
[src]
pub fn from_std(stream: UnixStream) -> Result<UnixStream>
[src]Consumes a UnixStream
in the standard library and returns a
nonblocking UnixStream
from this crate.
The returned stream will be associated with the given event loop
specified by handle
and is ready to perform I/O.
Panics
This function panics if thread-local runtime is not set.
The runtime is usually set implicitly when this function is called
from a future driven by a tokio runtime, otherwise runtime can be set
explicitly with Handle::enter
function.
pub fn pair() -> Result<(UnixStream, UnixStream)>
[src]
pub fn pair() -> Result<(UnixStream, UnixStream)>
[src]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 default event loop’s handle.
pub fn local_addr(&self) -> Result<SocketAddr>
[src]
pub fn local_addr(&self) -> Result<SocketAddr>
[src]Returns the socket address of the local half of this connection.
pub fn peer_addr(&self) -> Result<SocketAddr>
[src]
pub fn peer_addr(&self) -> Result<SocketAddr>
[src]Returns the socket address of the remote half of this connection.
pub fn peer_cred(&self) -> Result<UCred>
[src]
pub fn peer_cred(&self) -> Result<UCred>
[src]Returns effective credentials of the process which called connect
or pair
.
pub fn take_error(&self) -> Result<Option<Error>>
[src]
pub fn take_error(&self) -> Result<Option<Error>>
[src]Returns the value of the SO_ERROR
option.
Trait Implementations
impl AsRawFd for UnixStream
[src]
impl AsRawFd for UnixStream
[src]impl AsRef<UnixStream> for ReadHalf<'_>
[src]
impl AsRef<UnixStream> for ReadHalf<'_>
[src]fn as_ref(&self) -> &UnixStream
[src]
fn as_ref(&self) -> &UnixStream
[src]Performs the conversion.
impl AsRef<UnixStream> for WriteHalf<'_>
[src]
impl AsRef<UnixStream> for WriteHalf<'_>
[src]fn as_ref(&self) -> &UnixStream
[src]
fn as_ref(&self) -> &UnixStream
[src]Performs the conversion.
impl AsyncRead for UnixStream
[src]
impl AsyncRead for UnixStream
[src]unsafe fn prepare_uninitialized_buffer(&self, _: &mut [MaybeUninit<u8>]) -> bool
[src]
unsafe fn prepare_uninitialized_buffer(&self, _: &mut [MaybeUninit<u8>]) -> bool
[src]Prepares an uninitialized buffer to be safe to pass to read
. Returns
true
if the supplied buffer was zeroed out. Read more
impl AsyncWrite for UnixStream
[src]
impl AsyncWrite for UnixStream
[src]fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
[src]
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
[src]Attempt to write bytes from buf
into the object. Read more
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
[src]
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
[src]Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
impl Debug for UnixStream
[src]
impl Debug for UnixStream
[src]impl TryFrom<UnixStream> for UnixStream
[src]
impl TryFrom<UnixStream> for UnixStream
[src]fn try_from(stream: UnixStream) -> Result<Self>
[src]
fn try_from(stream: UnixStream) -> Result<Self>
[src]Consumes stream, returning the tokio I/O object.
This is equivalent to
UnixStream::from_std(stream)
.