pub trait Socket: Debug + Send + Sync {
// Required methods
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<()>;
// Provided methods
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§
sourcefn poll_recvmsg(
&mut self,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<(usize, Vec<OwnedFd>)>>
fn poll_recvmsg( &mut self, cx: &mut Context<'_>, buf: &mut [u8] ) -> Poll<Result<(usize, Vec<OwnedFd>)>>
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.
sourcefn poll_sendmsg(
&mut self,
cx: &mut Context<'_>,
buffer: &[u8],
fds: &[RawFd]
) -> Poll<Result<usize>>
fn poll_sendmsg( &mut self, cx: &mut Context<'_>, buffer: &[u8], fds: &[RawFd] ) -> Poll<Result<usize>>
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)
.
Provided Methods§
sourcefn can_pass_unix_fd(&self) -> bool
fn can_pass_unix_fd(&self) -> bool
Supports passing file descriptors.