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>
impl<D: AsRef<[u8]> + Send> BodyWriter<D>
pub async fn write( &mut self, data: D, cancellation: &Cancellation, ) -> Result<(), BodyError>
Sourcepub async fn write_frame(
&mut self,
frame: BodyFrame<D>,
cancellation: &Cancellation,
) -> Result<(), BodyError>
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.
pub async fn flush( &mut self, cancellation: &Cancellation, ) -> Result<(), BodyError>
pub fn close_write(&mut self, error: Option<BodyError>)
pub fn abort(&mut self)
Trait Implementations§
Source§impl<D> Drop for BodyWriter<D>
impl<D> Drop for BodyWriter<D>
Source§impl<D: AsRef<[u8]> + Send> WritableBody for BodyWriter<D>
impl<D: AsRef<[u8]> + Send> WritableBody for BodyWriter<D>
type Data = D
type Error = BodyError
Source§async fn write_frame(
&mut self,
frame: BodyFrame<D>,
cancellation: &Cancellation,
) -> Result<(), BodyError>
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>
async fn write( &mut self, data: D, cancellation: &Cancellation, ) -> Result<(), BodyError>
Write a nonfinal data frame. Use
write_frame to carry fields or end.async fn flush(&mut self, cancellation: &Cancellation) -> Result<(), BodyError>
fn close_write(&mut self, error: Option<BodyError>)
fn abort(&mut self)
Auto Trait Implementations§
impl<D> Freeze for BodyWriter<D>
impl<D> RefUnwindSafe for BodyWriter<D>where
Arc<Shared<D>>: RefUnwindSafe,
impl<D> Send for BodyWriter<D>
impl<D> Sync for BodyWriter<D>
impl<D> Unpin for BodyWriter<D>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more