Trait zbus::raw::Socket[][src]

pub trait Socket {
    const SUPPORTS_FD_PASSING: bool;

    fn recvmsg(&mut self, buffer: &mut [u8]) -> Result<(usize, Vec<OwnedFd>)>;
fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd]) -> Result<usize>;
fn close(&self) -> Result<()>; }
Expand description

Trait representing some transport layer over which the DBus protocol can be used

The crate provides an implementation of it for std’s UnixStream on unix platforms. You will want to implement this trait to integrate zbus with a async-runtime-aware implementation of the socket, for example.

Associated Constants

Whether this transport supports file descriptor passing

Required methods

Attempt to receive a message from the socket

On success, returns the number of bytes read as well as a Vec containing any associated file descriptors.

This method may return an error of kind WouldBlock instead if blocking for non-blocking sockets.

Attempt to send a message on the socket

On success, return the number of bytes written. There may be a partial write, in which case the caller is responsible of sending the remaining data by calling this method again until everything is written or it returns an error of kind WouldBlock.

If at least one byte has been written, then all the provided file descriptors will have been sent as well, and should not be provided again in subsequent calls. If Err(Errorkind::Wouldblock), none of the provided file descriptors were sent.

If the underlying transport does not support transmitting file descriptors, this will return Err(ErrorKind::InvalidInput).

Close the socket.

After this call, all reading and writing operations will fail.

NB: All currently implementations don’t block so this method will never return Err(Errorkind::Wouldblock).

Implementations on Foreign Types

Implementors