pub trait UnixStreamExt: AsRawFd + FromRawFd {
// Required methods
fn connect_to_unix_addr(addr: &UnixSocketAddr) -> Result<Self, Error>
where Self: Sized;
fn connect_from_to_unix_addr(
from: &UnixSocketAddr,
to: &UnixSocketAddr,
) -> Result<Self, Error>
where Self: Sized;
// Provided methods
fn local_unix_addr(&self) -> Result<UnixSocketAddr, Error> { ... }
fn peer_unix_addr(&self) -> Result<UnixSocketAddr, Error> { ... }
fn send_fds(&self, bytes: &[u8], fds: &[RawFd]) -> Result<usize, Error> { ... }
fn recv_fds(
&self,
buf: &mut [u8],
fd_buf: &mut [RawFd],
) -> Result<(usize, usize), Error> { ... }
fn initial_peer_credentials(&self) -> Result<ConnCredentials, Error> { ... }
fn initial_peer_selinux_context(
&self,
buffer: &mut [u8],
) -> Result<usize, Error> { ... }
}Expand description
Extension trait for std::os::unix::net::UnixStream and nonblocking equivalents.
Required Methods§
Sourcefn connect_to_unix_addr(addr: &UnixSocketAddr) -> Result<Self, Error>where
Self: Sized,
fn connect_to_unix_addr(addr: &UnixSocketAddr) -> Result<Self, Error>where
Self: Sized,
Creates a connection to a listening path-based or abstract named socket.
Sourcefn connect_from_to_unix_addr(
from: &UnixSocketAddr,
to: &UnixSocketAddr,
) -> Result<Self, Error>where
Self: Sized,
fn connect_from_to_unix_addr(
from: &UnixSocketAddr,
to: &UnixSocketAddr,
) -> Result<Self, Error>where
Self: Sized,
Creates a path-based or abstract-named socket and connects to a listening socket.
Provided Methods§
Sourcefn local_unix_addr(&self) -> Result<UnixSocketAddr, Error>
fn local_unix_addr(&self) -> Result<UnixSocketAddr, Error>
Get the address of this socket, as a type that fully supports abstract addresses.
Sourcefn peer_unix_addr(&self) -> Result<UnixSocketAddr, Error>
fn peer_unix_addr(&self) -> Result<UnixSocketAddr, Error>
Returns the address of the other end of this stream, as a type that fully supports abstract addresses.
Sourcefn send_fds(&self, bytes: &[u8], fds: &[RawFd]) -> Result<usize, Error>
fn send_fds(&self, bytes: &[u8], fds: &[RawFd]) -> Result<usize, Error>
Sends file descriptors in addition to bytes.
Sourcefn recv_fds(
&self,
buf: &mut [u8],
fd_buf: &mut [RawFd],
) -> Result<(usize, usize), Error>
fn recv_fds( &self, buf: &mut [u8], fd_buf: &mut [RawFd], ) -> Result<(usize, usize), Error>
Receives file descriptors in addition to bytes.
Sourcefn initial_peer_credentials(&self) -> Result<ConnCredentials, Error>
fn initial_peer_credentials(&self) -> Result<ConnCredentials, Error>
Returns the credentials of the process that created the other end of this stream.
Sourcefn initial_peer_selinux_context(
&self,
buffer: &mut [u8],
) -> Result<usize, Error>
fn initial_peer_selinux_context( &self, buffer: &mut [u8], ) -> Result<usize, Error>
Returns the SELinux security context of the process that created the other end of this stream.
Will return an error on other operating systems than Linux or Android,
and also if running under kubernetes.
On success the number of bytes used is returned. (like Read)
The default security context is unconfined, without any trailing NUL.
A buffor of 50 bytes is probably always big enough.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl UnixStreamExt for UnixStream
impl UnixStreamExt for UnixStream
fn connect_to_unix_addr(addr: &UnixSocketAddr) -> Result<Self, Error>
fn connect_from_to_unix_addr( from: &UnixSocketAddr, to: &UnixSocketAddr, ) -> Result<Self, Error>
Source§impl UnixStreamExt for UnixStream
Available on crate feature mio_08 only.
impl UnixStreamExt for UnixStream
mio_08 only.