pub struct ObjectBody<'a, R> { /* private fields */ }Expand description
One object or pull body of a FrameReader, read as an AsyncRead.
A read returns body bytes until the chunk of length 0, and then end of
file. A read that meets the abandon marker, a codec error, or an error of
the stream fails with an io::Error, and every later read fails too.
- After the abandon marker,
is_abandonedreturnstrue, andfinish_abandonreads the message that must follow the marker. - After another failure,
take_errorreturns theErrorof the reader. Theio::Errorof the read does not keep the variant or its wire code.
The body keeps a partial chunk length in the reader, so a read that returns
Pending loses no byte. A read that is dropped before it completes leaves
the reader in a consistent state.
Implementations§
Source§impl<R: AsyncRead + Unpin> ObjectBody<'_, R>
impl<R: AsyncRead + Unpin> ObjectBody<'_, R>
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if the body ended with the chunk of length 0.
Sourcepub fn is_abandoned(&self) -> bool
pub fn is_abandoned(&self) -> bool
Returns true if the sender abandoned the body with the abandon
marker.
Sourcepub fn take_error(&mut self) -> Option<Error>
pub fn take_error(&mut self) -> Option<Error>
Takes the Error of the read that failed.
The error is a codec error, for example Error::LimitExceeded for a
chunk over the limit, or an Error::Io from the stream. The call
returns None if no read failed, if the abandon marker is the only
failure, or if an earlier call took the error.
Sourcepub async fn finish_abandon(self) -> Result<()>
pub async fn finish_abandon(self) -> Result<()>
Reads the message that must follow the abandon marker.
In an object of the push, an Abort message gives Ok. In a body of
the pull, an Error message gives the Error variant of its code.
§Errors
Error::Protocolif no read met the abandon marker.- In a body of the pull, the
Errorvariant of the code in theErrormessage, for exampleError::Internal. Error::Protocolif a message of another kind follows the marker.Error::Ioof kindUnexpectedEofif the stream ends before the message.- The errors of
FrameReader::read_messagefor the message.
Trait Implementations§
Auto Trait Implementations§
impl<'a, R> !RefUnwindSafe for ObjectBody<'a, R>
impl<'a, R> !UnwindSafe for ObjectBody<'a, R>
impl<'a, R> Forget for ObjectBody<'a, R>
impl<'a, R> Freeze for ObjectBody<'a, R>where
&'a mut FrameReader<R>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<ObjectName>: Freeze,
PhantomData<String>: Freeze,
*const dyn Error + Sync + Send is !null: Freeze,
PhantomData<dyn Error + Sync + Send>: Freeze,
*const ErrorResponse is !null: Freeze,
PhantomData<ErrorResponse>: Freeze,
*const () is !null: Freeze,
PhantomData<ErrorData<CustomOwner>>: Freeze,
impl<'a, R> Move for ObjectBody<'a, R>
impl<'a, R> Send for ObjectBody<'a, R>
impl<'a, R> Sync for ObjectBody<'a, R>
impl<'a, R> Unpin for ObjectBody<'a, R>
impl<'a, R> UnsafeUnpin for ObjectBody<'a, R>where
&'a mut FrameReader<R>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<ObjectName>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const dyn Error + Sync + Send is !null: UnsafeUnpin,
PhantomData<dyn Error + Sync + Send>: UnsafeUnpin,
*const ErrorResponse is !null: UnsafeUnpin,
PhantomData<ErrorResponse>: UnsafeUnpin,
*const () is !null: UnsafeUnpin,
PhantomData<ErrorData<CustomOwner>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> ⓘwhere
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> ⓘwhere
Self: Unpin,
Source§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self> ⓘwhere
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self> ⓘwhere
Self: Unpin,
Source§fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self> ⓘwhere
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self> ⓘwhere
Self: Unpin,
Source§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self> ⓘwhere
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self> ⓘwhere
Self: Unpin,
Source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> ⓘwhere
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> ⓘwhere
Self: Unpin,
buf. Read moreSource§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
limit bytes from it. Read more