Struct async_io_converse::AsyncWriteConverse
source · pub struct AsyncWriteConverse<W: AsyncWrite + Unpin, T: Serialize + DeserializeOwned + Unpin> { /* private fields */ }Expand description
Used to send messages to the connected peer. You may optionally receive replies to your messages as well.
You must drive the corresponding AsyncReadConverse in order to receive replies to your messages.
You can do this either by driving the Stream implementation, or calling AsyncReadConverse::drive_forever.
Implementations§
source§impl<W: AsyncWrite + Unpin, T: Serialize + DeserializeOwned + Unpin> AsyncWriteConverse<W, T>
impl<W: AsyncWrite + Unpin, T: Serialize + DeserializeOwned + Unpin> AsyncWriteConverse<W, T>
pub async fn with_inner<F: FnOnce(&W) -> R, R>(&self, f: F) -> R
source§impl<W: AsyncWrite + Unpin, T: Serialize + DeserializeOwned + Unpin> AsyncWriteConverse<W, T>
impl<W: AsyncWrite + Unpin, T: Serialize + DeserializeOwned + Unpin> AsyncWriteConverse<W, T>
sourcepub async fn ask(&mut self, message: T) -> Result<T, Error>
pub async fn ask(&mut self, message: T) -> Result<T, Error>
Send a message, and wait for a reply, with the default timeout. Shorthand for .awaiting both layers of .send(message).
sourcepub async fn ask_timeout(
&mut self,
timeout: Duration,
message: T
) -> Result<T, Error>
pub async fn ask_timeout(
&mut self,
timeout: Duration,
message: T
) -> Result<T, Error>
Send a message, and wait for a reply, up to timeout. Shorthand for .awaiting both layers of .send_timeout(message).
sourcepub async fn send(
&mut self,
message: T
) -> Result<impl Future<Output = Result<T, Error>>, Error>
pub async fn send(
&mut self,
message: T
) -> Result<impl Future<Output = Result<T, Error>>, Error>
Sends a message to the peer on the other side of the connection. This returns a future wrapped in a future. You must
.await the first layer to send the message, however .awaiting the second layer is optional. You only need to
.await the second layer if you care about the reply to your message. Waits up to the default timeout for a reply.
sourcepub async fn send_timeout(
&mut self,
timeout: Duration,
message: T
) -> Result<impl Future<Output = Result<T, Error>>, Error>
pub async fn send_timeout(
&mut self,
timeout: Duration,
message: T
) -> Result<impl Future<Output = Result<T, Error>>, Error>
Sends a message to the peer on the other side of the connection, waiting up to the specified timeout for a reply.
This returns a future wrapped in a future. You must .await the first layer to send the message, however
.awaiting the second layer is optional. You only need to .await the second layer if you care about the
reply to your message.