pub struct WriteConnection<Write: WriteHalf> { /* private fields */ }Expand description
A connection.
The low-level API to send messages.
§Cancel safety
All async methods of this type are cancel safe unless explicitly stated otherwise in its documentation.
Implementations§
Source§impl<Write: WriteHalf> WriteConnection<Write>
impl<Write: WriteHalf> WriteConnection<Write>
Sourcepub async fn send_call<Method>(
&mut self,
call: &Call<Method>,
fds: Vec<OwnedFd>,
) -> Result<()>
pub async fn send_call<Method>( &mut self, call: &Call<Method>, fds: Vec<OwnedFd>, ) -> Result<()>
Sends a method call.
The generic Method is the type of the method name and its input parameters. This should be
a type that can serialize itself to a complete method call message, i-e an object containing
method and parameter fields. This can be easily achieved using the serde::Serialize
derive:
use serde::{Serialize, Deserialize};
use serde_prefix_all::prefix_all;
#[prefix_all("org.example.ftl.")]
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "method", content = "parameters")]
enum MyMethods<'m> {
// The name needs to be the fully-qualified name of the error.
Alpha { param1: u32, param2: &'m str},
Bravo,
Charlie { param1: &'m str },
}The fds parameter contains file descriptors to send along with the call.
Sourcepub async fn send_reply<Params>(
&mut self,
reply: &Reply<Params>,
fds: Vec<OwnedFd>,
) -> Result<()>
pub async fn send_reply<Params>( &mut self, reply: &Reply<Params>, fds: Vec<OwnedFd>, ) -> Result<()>
Send a reply over the socket.
The generic parameter Params is the type of the successful reply. This should be a type
that can serialize itself as the parameters field of the reply.
The fds parameter contains file descriptors to send along with the reply.
Sourcepub async fn send_error<ReplyError>(
&mut self,
error: &ReplyError,
fds: Vec<OwnedFd>,
) -> Result<()>
pub async fn send_error<ReplyError>( &mut self, error: &ReplyError, fds: Vec<OwnedFd>, ) -> Result<()>
Send an error reply over the socket.
The generic parameter ReplyError is the type of the error reply. This should be a type
that can serialize itself to the whole reply object, containing error and parameter
fields. This can be easily achieved using the serde::Serialize derive (See the code
snippet in super::ReadConnection::receive_reply documentation for an example).
The fds parameter contains file descriptors to send along with the error.
Sourcepub fn enqueue_call<Method>(
&mut self,
call: &Call<Method>,
fds: Vec<OwnedFd>,
) -> Result<()>
pub fn enqueue_call<Method>( &mut self, call: &Call<Method>, fds: Vec<OwnedFd>, ) -> Result<()>
Enqueue a call to be sent over the socket.
Similar to WriteConnection::send_call, except that the call is not sent immediately but
enqueued for later sending. This is useful when you want to send multiple calls in a
batch.
The fds parameter contains file descriptors to send along with the call.
Sourcepub fn write_half(&self) -> &Write
pub fn write_half(&self) -> &Write
The underlying write half of the socket.