[−][src]Struct tokio::net::UnixStream
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]
pub async fn connect<P>(path: P) -> Result<UnixStream> where
P: AsRef<Path>, [src]
P: AsRef<Path>,
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]
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]
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]
Returns the socket address of the local half of this connection.
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]
Returns effective credentials of the process which called connect or pair.
pub fn take_error(&self) -> Result<Option<Error>>[src]
Returns the value of the SO_ERROR option.
pub fn shutdown(&self, how: Shutdown) -> Result<()>[src]
Shuts 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).
pub fn split<'a>(&'a mut self) -> (ReadHalf<'a>, WriteHalf<'a>)[src]
Split a UnixStream into a read half and a write half, which can be used
to read and write the stream concurrently.
This method is more efficient than into_split, but the halves cannot be
moved into independently spawned tasks.
pub fn into_split(self) -> (OwnedReadHalf, OwnedWriteHalf)[src]
Splits a UnixStream into a read half and a write half, which can be used
to read and write the stream concurrently.
Unlike split, the owned halves can be moved to separate tasks, however
this comes at the cost of a heap allocation.
Note: Dropping the write half will shut down the write half of the
stream. This is equivalent to calling shutdown(Write) on the UnixStream.
Trait Implementations
impl AsRawFd for UnixStream[src]
impl<'_> AsRef<UnixStream> for ReadHalf<'_>[src]
fn as_ref(&self) -> &UnixStream[src]
impl<'_> AsRef<UnixStream> for WriteHalf<'_>[src]
fn as_ref(&self) -> &UnixStream[src]
impl AsRef<UnixStream> for OwnedReadHalf[src]
fn as_ref(&self) -> &UnixStream[src]
impl AsRef<UnixStream> for OwnedWriteHalf[src]
fn as_ref(&self) -> &UnixStream[src]
impl AsyncRead for UnixStream[src]
unsafe fn prepare_uninitialized_buffer(&self, _: &mut [MaybeUninit<u8>]) -> bool[src]
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
fn poll_read_buf<B: BufMut>(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut B
) -> Poll<Result<usize>> where
Self: Sized, [src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut B
) -> Poll<Result<usize>> where
Self: Sized,
impl AsyncWrite for UnixStream[src]
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>[src]
fn poll_shutdown(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>[src]
fn poll_write_buf<B: Buf>(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut B
) -> Poll<Result<usize, Error>> where
Self: Sized, [src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut B
) -> Poll<Result<usize, Error>> where
Self: Sized,
impl Debug for UnixStream[src]
impl TryFrom<UnixStream> for UnixStream[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(value: UnixStream) -> Result<Self, Self::Error>[src]
Consumes value, returning the mio I/O object.
See PollEvented::into_inner for more details about
resource deregistration that happens during the call.
impl TryFrom<UnixStream> for UnixStream[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(stream: UnixStream) -> Result<Self>[src]
Consumes stream, returning the tokio I/O object.
This is equivalent to
UnixStream::from_std(stream).
Auto Trait Implementations
impl !RefUnwindSafe for UnixStream
impl Send for UnixStream
impl Sync for UnixStream
impl Unpin for UnixStream
impl !UnwindSafe for UnixStream
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut Tⓘ[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,