pub trait LocalAsyncWriteBody<W> {
// Required methods
fn write_body(
self: Pin<&mut Self>,
w: Pin<&mut W>,
) -> impl Future<Output = Result<(), Error>>;
fn reset(self: Pin<&mut Self>) -> impl Future<Output = bool>;
}
Expand description
A trait implemented by local async streaming bodies.
§Examples
ⓘ
use conjure_error::Error;
use conjure_http::client::LocalAsyncWriteBody;
use std::pin::Pin;
use tokio_io::{AsyncWrite, AsyncWriteExt};
pub struct SimpleBodyWriter;
impl<W> LocalAsyncWriteBody<W> for SimpleBodyWriter
where
W: AsyncWrite,
{
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 {
true
}
}
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.