pub trait ScmSocket {
fn socket_fd(&self) -> RawFd;
fn send_with_fd<D: AsIobuf>(&self, buf: &[D], fd: RawFd) -> Result<usize> { ... }
fn send_with_fds<D: AsIobuf>(&self, buf: &[D], fd: &[RawFd]) -> Result<usize> { ... }
fn send_bufs_with_fd(&self, bufs: &[IoSlice<'_>], fd: RawFd) -> Result<usize> { ... }
fn send_bufs_with_fds(
&self,
bufs: &[IoSlice<'_>],
fd: &[RawFd]
) -> Result<usize> { ... }
fn recv_with_fd(&self, buf: IoSliceMut<'_>) -> Result<(usize, Option<File>)> { ... }
fn recv_with_fds(
&self,
buf: IoSliceMut<'_>,
fds: &mut [RawFd]
) -> Result<(usize, usize)> { ... }
fn recv_iovecs_with_fds(
&self,
iovecs: &mut [IoSliceMut<'_>],
fds: &mut [RawFd]
) -> Result<(usize, usize)> { ... }
}
Expand description
Trait for file descriptors can send and receive socket control messages via sendmsg
and
recvmsg
.
Required Methods§
Provided Methods§
sourcefn send_with_fd<D: AsIobuf>(&self, buf: &[D], fd: RawFd) -> Result<usize>
fn send_with_fd<D: AsIobuf>(&self, buf: &[D], fd: RawFd) -> Result<usize>
Sends the given data and file descriptor over the socket.
On success, returns the number of bytes sent.
The error is constructed via std::io::Error::last_os_error()
.
Arguments
buf
- A buffer of data to send on thesocket
.fd
- A file descriptors to be sent.
sourcefn send_with_fds<D: AsIobuf>(&self, buf: &[D], fd: &[RawFd]) -> Result<usize>
fn send_with_fds<D: AsIobuf>(&self, buf: &[D], fd: &[RawFd]) -> Result<usize>
Sends the given data and file descriptors over the socket.
On success, returns the number of bytes sent.
The error is constructed via std::io::Error::last_os_error()
.
Arguments
buf
- A buffer of data to send on thesocket
.fds
- A list of file descriptors to be sent.
sourcefn send_bufs_with_fd(&self, bufs: &[IoSlice<'_>], fd: RawFd) -> Result<usize>
fn send_bufs_with_fd(&self, bufs: &[IoSlice<'_>], fd: RawFd) -> Result<usize>
Sends the given data and file descriptor over the socket.
On success, returns the number of bytes sent.
The error is constructed via std::io::Error::last_os_error()
.
Arguments
bufs
- A slice of slices of data to send on thesocket
.fd
- A file descriptors to be sent.
sourcefn send_bufs_with_fds(&self, bufs: &[IoSlice<'_>], fd: &[RawFd]) -> Result<usize>
fn send_bufs_with_fds(&self, bufs: &[IoSlice<'_>], fd: &[RawFd]) -> Result<usize>
Sends the given data and file descriptors over the socket.
On success, returns the number of bytes sent.
The error is constructed via std::io::Error::last_os_error()
.
Arguments
bufs
- A slice of slices of data to send on thesocket
.fds
- A list of file descriptors to be sent.
sourcefn recv_with_fd(&self, buf: IoSliceMut<'_>) -> Result<(usize, Option<File>)>
fn recv_with_fd(&self, buf: IoSliceMut<'_>) -> Result<(usize, Option<File>)>
Receives data and potentially a file descriptor from the socket.
On success, returns the number of bytes and an optional file descriptor.
The error is constructed via std::io::Error::last_os_error()
.
Arguments
buf
- A buffer to receive data from the socket.vm
sourcefn recv_with_fds(
&self,
buf: IoSliceMut<'_>,
fds: &mut [RawFd]
) -> Result<(usize, usize)>
fn recv_with_fds(
&self,
buf: IoSliceMut<'_>,
fds: &mut [RawFd]
) -> Result<(usize, usize)>
Receives data and file descriptors from the socket.
On success, returns the number of bytes and file descriptors received as a tuple
(bytes count, files count)
.
The error is constructed via std::io::Error::last_os_error()
.
Arguments
buf
- A buffer to receive data from the socket.fds
- A slice ofRawFd
s to put the received file descriptors into. On success, the number of valid file descriptors is indicated by the second element of the returned tuple. The caller owns these file descriptors, but they will not be closed on drop like aFile
-like type would be. It is recommended that each valid file descriptor gets wrapped in a drop type that closes it after this returns.
sourcefn recv_iovecs_with_fds(
&self,
iovecs: &mut [IoSliceMut<'_>],
fds: &mut [RawFd]
) -> Result<(usize, usize)>
fn recv_iovecs_with_fds(
&self,
iovecs: &mut [IoSliceMut<'_>],
fds: &mut [RawFd]
) -> Result<(usize, usize)>
Receives data and file descriptors from the socket.
On success, returns the number of bytes and file descriptors received as a tuple
(bytes count, files count)
.
The error is constructed via std::io::Error::last_os_error()
.
Arguments
iovecs
- A slice of buffers to store received data.offset
- An offset forbufs
. The firstoffset
bytes inbufs
won’t be touched. Returns an error ifoffset
is larger than or equal to the total size ofbufs
.fds
- A slice ofRawFd
s to put the received file descriptors into. On success, the number of valid file descriptors is indicated by the second element of the returned tuple. The caller owns these file descriptors, but they will not be closed on drop like aFile
-like type would be. It is recommended that each valid file descriptor gets wrapped in a drop type that closes it after this returns.