Skip to main content

WritableBody

Trait WritableBody 

Source
pub trait WritableBody: Send {
    type Data: AsRef<[u8]> + Send;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn write_frame(
        &mut self,
        frame: BodyFrame<Self::Data>,
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn flush(
        &mut self,
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn close_write(&mut self, error: Option<Self::Error>);
    fn abort(&mut self);

    // Provided method
    fn write(
        &mut self,
        data: Self::Data,
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send { ... }
}
Expand description

A body producer accepting owned frames with backpressure. Normal closure preserves accepted frames; failure abandons unfinished output. Flushing exposes accepted frames to the consumer, without promising peer receipt.

Required Associated Types§

Source

type Data: AsRef<[u8]> + Send

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn write_frame( &mut self, frame: BodyFrame<Self::Data>, cancellation: &Cancellation, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Accept one whole frame. Headers follow all data; a terminal frame closes output atomically with acceptance. Later writes fail. Queue capacity becoming available does not mean the transport has released its buffers.

Source

fn flush( &mut self, cancellation: &Cancellation, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Source

fn close_write(&mut self, error: Option<Self::Error>)

Source

fn abort(&mut self)

Provided Methods§

Source

fn write( &mut self, data: Self::Data, cancellation: &Cancellation, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Write a nonfinal data frame. Use write_frame to carry fields or end.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<W: WritableBody + ?Sized> WritableBody for &mut W

Source§

type Data = <W as WritableBody>::Data

Source§

type Error = <W as WritableBody>::Error

Source§

async fn write_frame( &mut self, frame: BodyFrame<Self::Data>, cancellation: &Cancellation, ) -> Result<(), Self::Error>

Source§

async fn write( &mut self, data: Self::Data, cancellation: &Cancellation, ) -> Result<(), Self::Error>

Source§

async fn flush( &mut self, cancellation: &Cancellation, ) -> Result<(), Self::Error>

Source§

fn close_write(&mut self, error: Option<Self::Error>)

Source§

fn abort(&mut self)

Implementors§