pub struct ReadConnection<Read: ReadHalf> { /* private fields */ }Expand description
A connection that can only be used for reading.
§Cancel safety
All async methods of this type are cancel safe unless explicitly stated otherwise in its documentation.
Implementations§
Source§impl<Read: ReadHalf> ReadConnection<Read>
impl<Read: ReadHalf> ReadConnection<Read>
Sourcepub async fn receive_reply<'r, ReplyParams, ReplyError>(
&'r mut self,
) -> Result<(Result<ReplyParams, ReplyError>, Vec<OwnedFd>)>
pub async fn receive_reply<'r, ReplyParams, ReplyError>( &'r mut self, ) -> Result<(Result<ReplyParams, ReplyError>, Vec<OwnedFd>)>
Receives a method call reply.
The generic parameters needs some explanation:
ReplyParamsis the type of the successful reply. This should be a type that can deserialize itself from theparametersfield of the reply.ReplyErroris the type of the error reply. This should be a type that can deserialize itself from the whole reply object itself and must fail when there is noerrorfield in the object. This can be easily achieved using thezlink::ReplyErrorderive:
use zlink_core::ReplyError;
#[derive(Debug, ReplyError)]
#[zlink(
interface = "org.example.ftl",
// Not needed in the real code because you'll use `ReplyError` through `zlink` crate.
crate = "zlink_core",
)]
enum MyError {
Alpha { param1: u32, param2: String },
Bravo,
Charlie { param1: String },
}Returns the reply and any file descriptors received (std only).
Sourcepub async fn receive_call<'m, Method>(
&'m mut self,
) -> Result<(Call<Method>, Vec<OwnedFd>)>where
Method: Deserialize<'m> + Debug,
pub async fn receive_call<'m, Method>(
&'m mut self,
) -> Result<(Call<Method>, Vec<OwnedFd>)>where
Method: Deserialize<'m> + Debug,
Receive a method call over the socket.
The generic Method is the type of the method name and its input parameters. This should be
a type that can deserialize itself from a complete method call message, i-e an object
containing method and parameter fields. This can be easily achieved using the
serde::Deserialize derive (See the code snippet in super::WriteConnection::send_call
documentation for an example).
Returns the call and any file descriptors received (std only).