pub struct BodyReader<D = Vec<u8>> { /* private fields */ }Expand description
The readable half of a bounded, single-producer body.
Byte limits count data and field name/value bytes; item limits count every frame, including empty data and headers. Oversized frames are rejected rather than waiting forever. Owners may retain additional storage. Dropping/closing the reader abandons queued frames and wakes the writer. A temporarily empty open body is neither ready nor exhausted.
Implementations§
Source§impl<D: AsRef<[u8]> + Send> BodyReader<D>
impl<D: AsRef<[u8]> + Send> BodyReader<D>
Sourcepub fn bounded(max_bytes: usize, max_chunks: usize) -> (Self, BodyWriter<D>)
pub fn bounded(max_bytes: usize, max_chunks: usize) -> (Self, BodyWriter<D>)
Create independently movable input/output halves. Panics for zero limits.
Sourcepub fn with_length(
max_bytes: usize,
max_chunks: usize,
length: u64,
) -> (Self, BodyWriter<D>)
pub fn with_length( max_bytes: usize, max_chunks: usize, length: u64, ) -> (Self, BodyWriter<D>)
Declare total representation length; protocol framing checks actual size.
Trait Implementations§
Source§impl<D> Drop for BodyReader<D>
impl<D> Drop for BodyReader<D>
Source§impl<D: AsRef<[u8]> + Send> ReadableBody for BodyReader<D>
impl<D: AsRef<[u8]> + Send> ReadableBody for BodyReader<D>
type Error = BodyError
Source§fn is_ready(&self) -> bool
fn is_ready(&self) -> bool
Whether another read can proceed without waiting for produced data. Read more
Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Whether no unread payload frames remain. False can mean unknown; an open
queue with no frames is not exhausted. This does not suppress read errors.
Source§fn length(&self) -> Option<u64>
fn length(&self) -> Option<u64>
Total representation length, independent of the current read position.
Source§fn close(&mut self, error: Option<BodyError>)
fn close(&mut self, error: Option<BodyError>)
Abandon further application reads, optionally reporting their failure. Read more
Source§async fn read(
&mut self,
cancellation: &Cancellation,
) -> Result<BodyFrame<D>, BodyError>
async fn read( &mut self, cancellation: &Cancellation, ) -> Result<BodyFrame<D>, BodyError>
Read one owned frame. Pre-cancellation prevents consumption. The caller
stops after
frame.is_end(); subsequent reads return BodyFrame::End.
Headers occur at most once, after all data. Dropping a pending read is
not transport retirement, and must not lose an unreturned queued frame.Source§fn may_have_trailers(&self) -> bool
fn may_have_trailers(&self) -> bool
Whether this body can emit trailing headers. HTTP/1 needs this before
reading to choose chunked framing, even when the data length is known.
Returning false promises that no Headers frame will be produced.
fn is_rewindable(&self) -> bool
Auto Trait Implementations§
impl<D> Freeze for BodyReader<D>
impl<D> RefUnwindSafe for BodyReader<D>where
Arc<Shared<D>>: RefUnwindSafe,
impl<D> Send for BodyReader<D>
impl<D> Sync for BodyReader<D>
impl<D> Unpin for BodyReader<D>
impl<D> UnsafeUnpin for BodyReader<D>where
Arc<Shared<D>>: UnsafeUnpin,
impl<D> UnwindSafe for BodyReader<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