Struct UnixStream
pub struct UnixStream { /* private fields */ }
A non-blocking Unix stream socket.
Implementations
impl UnixStream
fn connect<P: AsRef<Path>>(path: P) -> Result<UnixStream>Connects to the socket named by
path.This may return a
WouldBlockin which case the socket connection cannot be completed immediately. Usually it means the backlog is full.fn connect_addr(address: &SocketAddr) -> Result<UnixStream>Connects to the socket named by
address.This may return a
WouldBlockin which case the socket connection cannot be completed immediately. Usually it means the backlog is full.fn from_std(stream: UnixStream) -> UnixStreamCreates a new
UnixStreamfrom a standardnet::UnixStream.This function is intended to be used to wrap a Unix stream from the standard library in the Mio equivalent. The conversion assumes nothing about the underlying stream; it is left up to the user to set it in non-blocking mode.
Note
The Unix stream here will not have
connectcalled on it, so it should already be connected via some other means (be it manually, or the standard library).fn pair() -> Result<(UnixStream, UnixStream)>Creates an unnamed pair of connected sockets.
Returns two
UnixStreams which are connected to each other.fn local_addr(&self) -> Result<SocketAddr>Returns the socket address of the local half of this connection.
fn peer_addr(&self) -> Result<SocketAddr>Returns the socket address of the remote half of this connection.
fn take_error(&self) -> Result<Option<Error>>Returns the value of the
SO_ERRORoption.fn shutdown(&self, how: Shutdown) -> Result<()>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).fn try_io<F, T>(&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; # #
Trait Implementations
impl AsFd for UnixStream
fn as_fd(&self) -> BorrowedFd<'_>
impl AsRawFd for UnixStream
fn as_raw_fd(&self) -> RawFd
impl Debug for UnixStream
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl From<OwnedFd> for UnixStream
fn from(fd: OwnedFd) -> Self
impl FromRawFd for UnixStream
unsafe fn from_raw_fd(fd: RawFd) -> UnixStreamConverts a
RawFdto aUnixStream.Notes
The caller is responsible for ensuring that the socket is in non-blocking mode.
impl IntoRawFd for UnixStream
fn into_raw_fd(self) -> RawFd
impl Read for UnixStream
fn read(&mut self, buf: &mut [u8]) -> Result<usize>fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
impl Source for UnixStream
fn register(&mut self, registry: &Registry, token: Token, interests: Interest) -> Result<()>fn reregister(&mut self, registry: &Registry, token: Token, interests: Interest) -> Result<()>fn deregister(&mut self, registry: &Registry) -> Result<()>
impl Write for UnixStream
fn write(&mut self, buf: &[u8]) -> Result<usize>fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>fn flush(&mut self) -> Result<()>
Auto Trait Implementations
impl !Freeze for UnixStream
impl RefUnwindSafe for UnixStream
impl Send for UnixStream
impl Sync for UnixStream
impl Unpin for UnixStream
impl UnsafeUnpin for UnixStream
impl UnwindSafe for UnixStream
Blanket Implementations
impl<T> Any for UnixStream
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for UnixStream
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for UnixStream
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for UnixStream
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for UnixStream
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for UnixStream
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for UnixStream
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>