pub trait ReadHalf:
Debug
+ Send
+ Sync
+ 'static {
// Provided methods
fn receive_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
seq: u64,
already_received_bytes: &'life1 mut Vec<u8>,
already_received_fds: &'life2 mut Vec<OwnedFd>,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn recvmsg<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, Vec<OwnedFd>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn can_pass_unix_fd(&self) -> bool { ... }
fn peer_credentials<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionCredentials>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
The read half of a socket.
See Socket
for more details.
Provided Methods§
Sourcefn receive_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
seq: u64,
already_received_bytes: &'life1 mut Vec<u8>,
already_received_fds: &'life2 mut Vec<OwnedFd>,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn receive_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
seq: u64,
already_received_bytes: &'life1 mut Vec<u8>,
already_received_fds: &'life2 mut Vec<OwnedFd>,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Receive a message on the socket.
This is the higher-level method to receive a full D-Bus message.
The default implementation uses recvmsg
to receive the message. Implementers should
override either this or recvmsg
. Note that if you override this method, zbus will not be
able perform an authentication handshake and hence will skip the handshake. Therefore your
implementation will only be useful for pre-authenticated connections or connections that do
not require authentication.
§Parameters
seq
: The sequence number of the message. The returned message should have this sequence.already_received_bytes
: Sometimes, zbus already received some bytes from the socket belonging to the first message(s) (as part of the connection handshake process). This is the buffer containing those bytes (if any). If you’re implementing this method, most likely you can safely ignore this parameter.already_received_fds
: Same goes for file descriptors belonging to first messages.
Sourcefn recvmsg<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, Vec<OwnedFd>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recvmsg<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, Vec<OwnedFd>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Attempt to receive bytes from the socket.
On success, returns the number of bytes read as well as a Vec
containing
any associated file descriptors.
The default implementation simply panics. Implementers must override either read_message
or this method.
Sourcefn can_pass_unix_fd(&self) -> bool
fn can_pass_unix_fd(&self) -> bool
Supports passing file descriptors.
Default implementation returns false
.
Sourcefn peer_credentials<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionCredentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn peer_credentials<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionCredentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return the peer credentials.
Trait Implementations§
Source§impl ReadHalf for Box<dyn ReadHalf>
impl ReadHalf for Box<dyn ReadHalf>
Source§fn can_pass_unix_fd(&self) -> bool
fn can_pass_unix_fd(&self) -> bool
Source§fn receive_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
seq: u64,
already_received_bytes: &'life1 mut Vec<u8>,
already_received_fds: &'life2 mut Vec<OwnedFd>,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn receive_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
seq: u64,
already_received_bytes: &'life1 mut Vec<u8>,
already_received_fds: &'life2 mut Vec<OwnedFd>,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn recvmsg<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, Vec<OwnedFd>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recvmsg<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, Vec<OwnedFd>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn peer_credentials<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionCredentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn peer_credentials<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionCredentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Implementations on Foreign Types§
Source§impl ReadHalf for Box<dyn ReadHalf>
impl ReadHalf for Box<dyn ReadHalf>
fn can_pass_unix_fd(&self) -> bool
fn receive_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
seq: u64,
already_received_bytes: &'life1 mut Vec<u8>,
already_received_fds: &'life2 mut Vec<OwnedFd>,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn recvmsg<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, Vec<OwnedFd>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn peer_credentials<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionCredentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl ReadHalf for Arc<Async<UnixStream>>
impl ReadHalf for Arc<Async<UnixStream>>
Source§fn can_pass_unix_fd(&self) -> bool
fn can_pass_unix_fd(&self) -> bool
Supports passing file descriptors.