[−][src]Trait conjure_http::client::AsyncWriteBody
A trait implemented by async streaming bodies.
This trait can most easily be implemented with the async-trait crate.
Examples
ⓘThis example is not tested
use async_trait::async_trait; use conjure_error::Error; use conjure_http::client::AsyncWriteBody; use std::pin::Pin; use tokio_io::{AsyncWrite, AsyncWriteExt}; pub struct SimpleBodyWriter; #[async_trait] impl<W> AsyncWriteBody<W> for SimpleBodyWriter where W: AsyncWrite + Send, { async fn write_body(self: Pin<&mut Self>, mut w: Pin<&mut W>) -> Result<(), Error> { w.write_all(b"hello world").await.map_err(Error::internal_safe) } async fn reset(self: Pin<&mut Self>) -> bool where W: 'async_trait, { true } }
Required methods
#[must_use]fn write_body<'life0, 'life1, 'async_trait>(
self: Pin<&'life0 mut Self>,
w: Pin<&'life1 mut W>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
self: Pin<&'life0 mut Self>,
w: Pin<&'life1 mut W>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Writes the body out, in its entirety.
Behavior is unspecified if this method is called twice without a successful call to reset in between.
#[must_use]fn reset<'life0, 'async_trait>(
self: Pin<&'life0 mut Self>
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where
W: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
self: Pin<&'life0 mut Self>
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where
W: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Attempts to reset the body so that it can be written out again.
Returns true if successful. Behavior is unspecified if this is not called after a call to write_body.