logo

Trait zbus::Socket[][src]

pub trait Socket: Debug + Send + Sync {
    fn poll_recvmsg(
        &mut self,
        cx: &mut Context<'_>,
        buf: &mut [u8]
    ) -> Poll<Result<(usize, Vec<OwnedFd>)>>;
fn poll_sendmsg(
        &mut self,
        cx: &mut Context<'_>,
        buffer: &[u8],
        fds: &[RawFd]
    ) -> Poll<Result<usize>>;
fn close(&self) -> Result<()>;
fn as_raw_fd(&self) -> RawFd; }
Expand description

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

The crate provides implementations for async_io and tokio’s UnixStream wrappers if you enable the corresponding crate features (async_io is enabled by default).

You can implement it manually to integrate with other runtimes or other dbus transports. Feel free to submit pull requests to add support for more runtimes to zbus itself so rust’s orphan rules don’t force the use of a wrapper struct (and to avoid duplicating the work across many projects).

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.

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 the underlying transport does not support transmitting file descriptors, this will return Err(ErrorKind::InvalidInput).

Close the socket.

After this call, it is valid for all reading and writing operations to fail.

Return the raw file descriptor backing this transport, if any.

This is used to back some internal platform-specific functions.

Implementations on Foreign Types

Implementors