Trait zbus::Socket

source ·
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 can_pass_unix_fd(&self) -> bool { ... } fn peer_pid(&self) -> Result<Option<u32>> { ... } fn uid(&self) -> Result<Option<u32>> { ... } }
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.

Provided Methods§

Supports passing file descriptors.

Return the peer PID.

Return the User ID, if any.

Trait Implementations§

Supports passing file descriptors.
Attempt to receive a message from the socket. Read more
Attempt to send a message on the socket Read more
Close the socket. Read more
Return the peer PID.
Return the User ID, if any.

Implementations on Foreign Types§

Implementors§