pub trait ReadBodyIntoBytes: Sized {
// Required method
async fn read_into_bytes_or_pieces(
self,
declared_size: Option<usize>,
min_size: usize,
max_size: usize,
) -> Result<(Bytes, Vec<HeaderMap>), ErrorWithBodyPieces<ReadBodyError, Self>>;
// Provided methods
async fn read_into_bytes(
self,
max_size: usize,
) -> Result<(Bytes, Vec<HeaderMap>), ReadBodyError> { ... }
async fn read_into_string_or_pieces(
self,
declared_size: Option<usize>,
min_size: usize,
max_size: usize,
) -> Result<(String, Vec<HeaderMap>), ErrorWithBodyPieces<ReadBodyError, Self>> { ... }
async fn read_into_string(
self,
max_size: usize,
) -> Result<(String, Vec<HeaderMap>), ReadBodyError> { ... }
}
Expand description
See also BodyReader.
Required Methods§
Sourceasync fn read_into_bytes_or_pieces(
self,
declared_size: Option<usize>,
min_size: usize,
max_size: usize,
) -> Result<(Bytes, Vec<HeaderMap>), ErrorWithBodyPieces<ReadBodyError, Self>>
async fn read_into_bytes_or_pieces( self, declared_size: Option<usize>, min_size: usize, max_size: usize, ) -> Result<(Bytes, Vec<HeaderMap>), ErrorWithBodyPieces<ReadBodyError, Self>>
Read entire Body into Bytes and trailers.
If declared_size
is not None then that’s the size we expect. Otherwise
we’ll try to read up to max_size
and will expect at least min_size
.
If we read less than min_size
or we did not read all the way to EOF will return a
ReadBodyError with FileTooLarge and BodyPieces, the
latter of which can be used by the caller to reconstruct the original body, e.g. with
BodyReader::new_with_first_bytes.
Provided Methods§
Sourceasync fn read_into_bytes(
self,
max_size: usize,
) -> Result<(Bytes, Vec<HeaderMap>), ReadBodyError>
async fn read_into_bytes( self, max_size: usize, ) -> Result<(Bytes, Vec<HeaderMap>), ReadBodyError>
Read entire Body into Bytes and trailers.
If we we did not read all the way to EOF will return a FileTooLarge error.
Sourceasync fn read_into_string_or_pieces(
self,
declared_size: Option<usize>,
min_size: usize,
max_size: usize,
) -> Result<(String, Vec<HeaderMap>), ErrorWithBodyPieces<ReadBodyError, Self>>
async fn read_into_string_or_pieces( self, declared_size: Option<usize>, min_size: usize, max_size: usize, ) -> Result<(String, Vec<HeaderMap>), ErrorWithBodyPieces<ReadBodyError, Self>>
Read entire Body into String and trailers.
See read_into_bytes.
Sourceasync fn read_into_string(
self,
max_size: usize,
) -> Result<(String, Vec<HeaderMap>), ReadBodyError>
async fn read_into_string( self, max_size: usize, ) -> Result<(String, Vec<HeaderMap>), ReadBodyError>
Read entire Body into String and trailers.
If we we did not read all the way to EOF will return a FileTooLarge error.
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.