Struct cros_asyncv2::UnixSeqPacket
source · [−]pub struct UnixSeqPacket {
fd: Arc<SafeDescriptor>,
}
Expand description
A Unix SOCK_SEQPACKET
.
Fields
fd: Arc<SafeDescriptor>
Implementations
sourceimpl SeqPacket
impl SeqPacket
sourcepub async fn connect<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn connect<P: AsRef<Path>>(path: P) -> Result<Self>
Open a SOCK_SEQPACKET
connection to socket named by path
.
sourcepub fn pair() -> Result<(Self, Self)>
pub fn pair() -> Result<(Self, Self)>
Creates a pair of connected SOCK_SEQPACKET
sockets.
Both returned file descriptors have the CLOEXEC
flag set.s
sourcepub async fn next_packet_size(&self) -> Result<usize>
pub async fn next_packet_size(&self) -> Result<usize>
Gets the number of bytes in the next packet. This blocks as if recv
were called,
respecting the blocking and timeout settings of the underlying socket.
sourcepub async fn send(&self, buf: &[u8]) -> Result<usize>
pub async fn send(&self, buf: &[u8]) -> Result<usize>
Writes data from buf
to the socket.
Returns the number of bytes written to the socket. Note that when using I/O drivers like
io_uring the data will be copied into an intermediate buffer before it is written to the
socket and so this function is best suited for sending small amounts of data. Callers that
want to avoid the intermediate buffer should use send_iobuf
instead.
sourcepub async fn send_with_fds(&self, buf: &[u8], fds: &[RawFd]) -> Result<usize>
pub async fn send_with_fds(&self, buf: &[u8], fds: &[RawFd]) -> Result<usize>
Writes buf
with the provided file descriptors to the socket.
Returns the number of bytes written to the socket. Like with send
, this method may copy
both the data and the fds into an intermediate buffer before writing them to the socket.
Callers that want to avoid copying should use send_iobuf_with_fds
instead.
sourcepub async fn send_iobuf<B: AsIoBufs + Unpin + 'static>(
&self,
buf: B
) -> (Result<usize>, B)
pub async fn send_iobuf<B: AsIoBufs + Unpin + 'static>(
&self,
buf: B
) -> (Result<usize>, B)
Writes data from buf
to the socket.
This function is like send
but takes an owned buffer instead, avoiding the need to first
copy the data into an intermediate buffer.
sourcepub async fn send_iobuf_with_fds<B: AsIoBufs + Unpin + 'static>(
&self,
buf: B,
fds: &[RawFd]
) -> (Result<usize>, B)
pub async fn send_iobuf_with_fds<B: AsIoBufs + Unpin + 'static>(
&self,
buf: B,
fds: &[RawFd]
) -> (Result<usize>, B)
Writes data from buf
with the provided file descriptors to the socket.
Like send_with_fds
but doesn’t require copying the data into an intermediate buffer first.
Returns the number of bytes written to the socket.
sourcepub async fn recv(&self, buf: &mut [u8]) -> Result<usize>
pub async fn recv(&self, buf: &mut [u8]) -> Result<usize>
Reads data from the socket into buf
.
Returns the number of bytes read from the socket. Note that when using I/O drivers like
io_uring the data will first be read into an intermediate buffer before it is copied into
buf
and so this function is best suited for reading small amounts of data. Callers that
want to avoid the intermediate buffer should use recv_iobuf
instead.
sourcepub async fn recv_with_fds(
&self,
buf: &mut [u8],
fds: &mut [RawFd]
) -> Result<(usize, usize)>
pub async fn recv_with_fds(
&self,
buf: &mut [u8],
fds: &mut [RawFd]
) -> Result<(usize, usize)>
Reads data from the socket into buf
and any file descriptors into fds
.
Returns the number of bytes read from the socket and the number of file descriptors
received. Note that when using I/O drivers like io_uring the data will first be read into an
intermediate buffer before it is copied into buf
and so this function is best suited for
reading small amounts of data. Callers that want to avoid the intermediate buffer should use
recv_iobuf_with_fds
instead.
sourcepub async fn recv_iobuf<B: AsIoBufs + Unpin + 'static>(
&self,
buf: B
) -> (Result<usize>, B)
pub async fn recv_iobuf<B: AsIoBufs + Unpin + 'static>(
&self,
buf: B
) -> (Result<usize>, B)
Reads data from the socket into buf
.
This function is like recv
but takes an owned buffer instead, avoiding the need to first
copy the data into an intermediate buffer.
sourcepub async fn recv_iobuf_with_fds<B: AsIoBufs + Unpin + 'static>(
&self,
buf: B,
fds: &mut [RawFd]
) -> (Result<(usize, usize)>, B)
pub async fn recv_iobuf_with_fds<B: AsIoBufs + Unpin + 'static>(
&self,
buf: B,
fds: &mut [RawFd]
) -> (Result<(usize, usize)>, B)
Reads data from the socket into buf
and any file descriptors into fds
.
Like recv_with_fds
but doesn’t require copying the data into an intermediate buffer first.
Returns the number of bytes read from the socket as well as the number of file descriptors
received.
sourcepub async fn recv_as_vec(&self) -> Result<Vec<u8>>
pub async fn recv_as_vec(&self) -> Result<Vec<u8>>
Reads data from the socket into a Vec<u8>
.