pub trait AsyncDecodeRecord {
// Required method
async fn decode_record<'a, T: HasRType + 'a>(
&'a mut self,
) -> Result<Option<&'a T>>;
// Provided method
async fn decode_records<T: HasRType + Clone>(&mut self) -> Result<Vec<T>>
where Self: Sized { ... }
}async only.Expand description
Async trait for types that decode DBN records of a particular type.
Required Methods§
Sourceasync fn decode_record<'a, T: HasRType + 'a>(
&'a mut self,
) -> Result<Option<&'a T>>
async fn decode_record<'a, T: HasRType + 'a>( &'a mut self, ) -> Result<Option<&'a T>>
Tries to decode a reference to a single record of type T. Returns Ok(None)
if the input has been exhausted.
§Errors
This function returns an error if the underlying reader returns an error of a
kind other than io::ErrorKind::UnexpectedEof upon reading.
If the next record is of a different type than T, an
Error::Conversion will be returned.
If the length property of the record is invalid, an
Error::Decode will be returned.
§Cancel safety
This method is cancel safe. It can be used within a tokio::select! statement
without the potential for corrupting the input stream.
Provided Methods§
Sourceasync fn decode_records<T: HasRType + Clone>(&mut self) -> Result<Vec<T>>where
Self: Sized,
async fn decode_records<T: HasRType + Clone>(&mut self) -> Result<Vec<T>>where
Self: Sized,
Tries to decode all records into a Vec. This eagerly decodes the data.
§Errors
This function returns an error if the underlying reader returns an error of a
kind other than io::ErrorKind::UnexpectedEof upon reading.
If any of the records is of a different type than T, an
Error::Conversion will be returned.
If the length property of any of the records is invalid, a
Error::Decode will be returned.
§Cancel safety
This method is not cancellation safe. If used within a tokio::select! statement
partially decoded records will be lost and the stream may be corrupted.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.