pub trait BytesSource {
// Required method
fn pop_chunk(&mut self, limit: usize) -> (Bytes, usize);
}
Expand description
A source of one or more buffers which can be converted into Bytes
buffers on demand
The purpose of this data type is to defer conversion as long as possible, so that no heap allocation is required in case no data is writable.
Required Methods§
Sourcefn pop_chunk(&mut self, limit: usize) -> (Bytes, usize)
fn pop_chunk(&mut self, limit: usize) -> (Bytes, usize)
Returns the next chunk from the source of owned chunks.
This method will consume parts of the source.
Calling it will yield Bytes
elements up to the configured limit
.
The method returns a tuple:
- The first item is the yielded
Bytes
element. The element will be empty if the limit is zero or no more data is available. - The second item returns how many complete chunks inside the source had had been consumed. This can be less than 1, if a chunk inside the source had been truncated in order to adhere to the limit. It can also be more than 1, if zero-length chunks had been skipped.