Trait conjure_http::server::AsyncWriteBody

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

A trait implemented by asynchronous streaming bodies.

§Examples

use conjure_error::Error;
use conjure_http::server::AsyncWriteBody;
use std::pin::Pin;
use tokio_io::{AsyncWrite, AsyncWriteExt};

pub struct SimpleBodyWriter;

impl<W> AsyncWriteBody<W> for SimpleBodyWriter
where
    W: AsyncWrite + Send,
{
    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>> + Send

Writes the body out, in its entirety.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, W> AsyncWriteBody<W> for BoxAsyncWriteBody<'a, W>
where W: Send,