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.

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.

Flush all data in this connection’s buffer.

Blocking

Unless this connection has been set into non-blocking mode, this method is expected to block until all bytes in the buffer are written.

Errors

Any platform I/O errors will be bubbled up to the user.

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.

Shutdown this connection.

This should have the same effect as dropping this object, but any OS errors should be able to be caught.

Blocking

This function should never block.

Errors

Any OS errors should be bubbled up to the user.

Provided Methods

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.

Write a slice of data to the X11 server.

This calls the platform’s writing utility to write the slice, and returs the number of bytes written. By default, this is implemented as a call to send_slices.

Blocking

Same as send_slices_and_fds.

Errors

Same as send_slices.

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.

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.

Receive data from the X11 server into a single slice, in a non-blocking manner.

Errors

Same as non_blocking_recv_slices_and_fds.

Implementations on Foreign Types

Implementors