pub struct RequestBody(/* private fields */);Expand description
Request body abstraction that will implement a generic read/write interface that does not require mut self to operate upon and can be shared with threads. Peculiarities like transfer and content encoding are handled by the inner implementation and hidden from the actual endpoints.
§Concerning equality
Instances of RequestBody are only considered equal if they refer to the exact same underlying stream. The content of the stream is not considered when determining equality as that would require consuming the stream.
Implementations§
Source§impl RequestBody
impl RequestBody
Sourcepub fn new_with_data_ref<T: AsRef<[u8]>>(data: T) -> RequestBody ⓘ
pub fn new_with_data_ref<T: AsRef<[u8]>>(data: T) -> RequestBody ⓘ
For unit tests or mocks, will mimic new_with_content_length This will call to_vec() on the slice.
Sourcepub fn new_with_data(data: Vec<u8>) -> RequestBody ⓘ
pub fn new_with_data(data: Vec<u8>) -> RequestBody ⓘ
For unit tests or mocks, will mimic new_with_content_length
Sourcepub fn new_with_content_length<T: Read + Send + 'static>(
read: T,
len: u64,
) -> RequestBody ⓘ
pub fn new_with_content_length<T: Read + Send + 'static>( read: T, len: u64, ) -> RequestBody ⓘ
Uncompressed stream with known length.
Sourcepub fn new_chunked<T: Read + Send + 'static>(read: T) -> RequestBody ⓘ
pub fn new_chunked<T: Read + Send + 'static>(read: T) -> RequestBody ⓘ
Uncompressed Chunked stream. Content length is not known.
Sourcepub fn new_gzip_chunked<T: Read + Send + 'static>(
read: T,
) -> TiiResult<RequestBody>
pub fn new_gzip_chunked<T: Read + Send + 'static>( read: T, ) -> TiiResult<RequestBody>
Chunked stream that is gzip compressed. Neither compressed nor uncompressed content lengths are known.
Sourcepub fn new_gzip_with_uncompressed_length<T: Read + Send + 'static>(
read: T,
len: u64,
) -> TiiResult<RequestBody>
pub fn new_gzip_with_uncompressed_length<T: Read + Send + 'static>( read: T, len: u64, ) -> TiiResult<RequestBody>
GZIP stream with a known length of the uncompressed data. The size of the gzip payload is presumably smaller (not guaranteed) but otherwise unknown.
Sourcepub fn new_gzip_with_compressed_content_length<T: Read + Send + 'static>(
read: T,
len: u64,
) -> TiiResult<RequestBody>
pub fn new_gzip_with_compressed_content_length<T: Read + Send + 'static>( read: T, len: u64, ) -> TiiResult<RequestBody>
GZIP stream with a known length of the compressed data. The length of the uncompressed data is not known.
Source§impl RequestBody
impl RequestBody
Sourcepub fn as_read(&self) -> impl Read + '_
pub fn as_read(&self) -> impl Read + '_
Turns this struct into a generic Box Read impl.
Useful for calling some external library functions.
Sourcepub fn read_to_vec(&self) -> Result<Vec<u8>>
pub fn read_to_vec(&self) -> Result<Vec<u8>>
Reads all remaining data into a Vec<u8>
Sourcepub fn read_exact(&self, buf: &mut [u8]) -> Result<()>
pub fn read_exact(&self, buf: &mut [u8]) -> Result<()>
same as std::io::Read trait
Trait Implementations§
Source§impl Clone for RequestBody
impl Clone for RequestBody
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RequestBody
impl Debug for RequestBody
Source§impl PartialEq for RequestBody
impl PartialEq for RequestBody
Source§impl Read for &RequestBody
impl Read for &RequestBody
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more