Trait breadx::connection::Connection
source · [−]pub trait Connection {
fn send_slices_and_fds(
&mut self,
slices: &[IoSlice<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>;
fn recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>;
fn flush(&mut self) -> Result<()>;
fn non_blocking_recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>;
fn shutdown(&self) -> Result<()>;
fn send_slices(&mut self, slices: &[IoSlice<'_>]) -> Result<usize> { ... }
fn send_slice(&mut self, slice: &[u8]) -> Result<usize> { ... }
fn recv_slice_and_fds(
&mut self,
slice: &mut [u8],
fds: &mut Vec<Fd>
) -> Result<usize> { ... }
fn recv_slice(&mut self, slice: &mut [u8]) -> Result<usize> { ... }
fn non_blocking_recv_slice_and_fds(
&mut self,
slice: &mut [u8],
fds: &mut Vec<Fd>
) -> Result<usize> { ... }
}
Expand description
A “suitable byte stream” where communication with the X11 server can occur.
See the module level documentation for more details.
Required Methods
Write a series of I/O slices and a series of file descriptors to the X11 server.
This calls the platform’s writing utility to write the slices and
file descriptors, and returns the number of bytes written. If
the call succeeded, the fds
array should be empty after operation.
If the fds
array is empty, this function call is allowed to
degenerate to a standard vectored write.
Blocking
This operation may block under normal circumstances. However, if this
type implements AsRawFd
or AsRawSocket
, and if set_nonblocking
or an equivalent method has been called on this object earlier, then
this operation should not block, and return a WouldBlock
error if
it would.
Errors
Some Connection
implementations do not support FD passing. If an
FD is passed into these implementations, an unsupported()
Error
will be raised.
In addition, any platform I/O errors will be bubbled up to the user.
fn recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>
fn recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>
Read data to a series of I/O slices and a buffer for file descriptors.
This calls the platform’s reading utility to read into the buffers, and returns the total number of bytes read.
Blocking
This operation may block under normal circumstances. However, if this
type implements AsRawFd
or AsRawSocket
, and if set_nonblocking
or an equivalent method has been called on this object earlier, then
this operation should not block, and return a WouldBlock
error if
it would.
Errors
Any platform I/O errors will be bubbled up to the user.
fn non_blocking_recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>
fn non_blocking_recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>
Receive data from the X11 server into a set of I/O slices, in a non-blocking manner.
Blocking
Even if the connection is in blocking mode, this function should never block.
Errors
This will return a WouldBlock
I/O error if the function would
block. Otherwise, it should bubble up any platform I/O errors.
Provided Methods
fn send_slices(&mut self, slices: &[IoSlice<'_>]) -> Result<usize>
fn send_slices(&mut self, slices: &[IoSlice<'_>]) -> Result<usize>
Write a series of I/O slices to the X11 server.
This calls the platform’s writing utility to write the slices, and
returns the number of bytes written. By default, this is implemented
as a call to send_slices_and_fds
without any file descriptors.
Certain implementations can optimize away having to keep track
of file descriptors.
Blocking
Same as send_slices_and_fds
.
Errors
Same as send_slices_and_fds
.
fn send_slice(&mut self, slice: &[u8]) -> Result<usize>
fn send_slice(&mut self, slice: &[u8]) -> Result<usize>
Read data to a single I/O slice and a buffer for file descriptors.
This calls the platform’s reading utility to read into the buffers,
and returns the total number of bytes read. By default, this is
implemented as a call to recv_slices_and_fds
with a single
slice.
Blocking
Same as recv_slices_and_fds
.
Errors
Any platform I/O errors will be bubbled up to the user.
fn recv_slice(&mut self, slice: &mut [u8]) -> Result<usize>
fn recv_slice(&mut self, slice: &mut [u8]) -> Result<usize>
Read data for a single I/O slice.
This calls the platform’s reading utility to read into the buffer,
and returns the total number of bytes read. By default, this is
implemented as a call to recv_slice_and_fds
with a single slice.
Blocking
Same as recv_slices_and_fds
.
Errors
If recv_slice_and_fds
returns any file descriptors, this
function will return an invalid_state()
error. It is encouraged
for implementors to override this behavior so that this check is
not necessary.
In addition, any platform I/O errors will be bubbled up to the user.