LocalAsyncWriteBody

Trait LocalAsyncWriteBody 

Source
pub trait LocalAsyncWriteBody<W> {
    // Required method
    fn write_body(
        self,
        w: Pin<&mut W>,
    ) -> impl Future<Output = Result<(), Error>>;
}
Expand description

A trait implemented by local asynchronous streaming bodies.

§Examples

use conjure_error::Error;
use conjure_http::server::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, mut w: Pin<&mut W>) -> Result<(), Error> {
        w.write_all(b"hello world").await.map_err(Error::internal_safe)
    }
}

Required Methods§

Source

fn write_body(self, w: Pin<&mut W>) -> impl Future<Output = Result<(), Error>>

Writes the body out, in its entirety.

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.

Implementors§