Skip to main content

BodyWriter

Struct BodyWriter 

Source
pub struct BodyWriter<D = Vec<u8>> { /* private fields */ }
Expand description

The unique output half of a BodyReader body.

Finish with a terminal frame or close_write(None) to preserve queued frames. An error closes immediately and discards queued frames. Dropping unfinished output reports abandonment. A cancelled/pending write has not queued its frame; the supplied owner is dropped when that write future is dropped.

Implementations§

Source§

impl<D: AsRef<[u8]> + Send> BodyWriter<D>

Source

pub async fn write( &mut self, data: D, cancellation: &Cancellation, ) -> Result<(), BodyError>

Source

pub async fn write_frame( &mut self, frame: BodyFrame<D>, cancellation: &Cancellation, ) -> Result<(), BodyError>

Move a whole frame into the queue. Headers must follow all data; an end flag or End closes output atomically with accepting that frame. Capacity counts data bytes and field name/value bytes, plus every frame against the item limit. As with data, owners may retain additional memory.

Source

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

Source

pub fn close_write(&mut self, error: Option<BodyError>)

Source

pub fn abort(&mut self)

Trait Implementations§

Source§

impl<D> Drop for BodyWriter<D>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<D: AsRef<[u8]> + Send> WritableBody for BodyWriter<D>

Source§

type Data = D

Source§

type Error = BodyError

Source§

async fn write_frame( &mut self, frame: BodyFrame<D>, cancellation: &Cancellation, ) -> Result<(), BodyError>

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§

async fn write( &mut self, data: D, cancellation: &Cancellation, ) -> Result<(), BodyError>

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

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

Source§

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

Source§

fn abort(&mut self)

Auto Trait Implementations§

§

impl<D> Freeze for BodyWriter<D>
where Arc<Shared<D>>: Freeze,

§

impl<D> RefUnwindSafe for BodyWriter<D>
where Arc<Shared<D>>: RefUnwindSafe,

§

impl<D> Send for BodyWriter<D>
where Arc<Shared<D>>: Send,

§

impl<D> Sync for BodyWriter<D>
where Arc<Shared<D>>: Sync,

§

impl<D> Unpin for BodyWriter<D>
where Arc<Shared<D>>: Unpin,

§

impl<D> UnsafeUnpin for BodyWriter<D>
where Arc<Shared<D>>: UnsafeUnpin,

§

impl<D> UnwindSafe for BodyWriter<D>
where Arc<Shared<D>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.