pub struct Limit<'a, R: Reader + ?Sized> { /* private fields */ }
Expand description
Wraps a reader and limits the amount of data that can be read from it
This can be used for applying back pressure to the reader with flow control.
Implementations§
Trait Implementations§
Source§impl<R: Reader + ?Sized> Reader for Limit<'_, R>
impl<R: Reader + ?Sized> Reader for Limit<'_, R>
Source§fn current_offset(&self) -> VarInt
fn current_offset(&self) -> VarInt
Returns the currently read offset for the stream
Source§fn final_offset(&self) -> Option<VarInt>
fn final_offset(&self) -> Option<VarInt>
Returns the final offset for the stream
Source§fn has_buffered_fin(&self) -> bool
fn has_buffered_fin(&self) -> bool
Returns
true
if the reader has the final offset bufferedSource§fn is_consumed(&self) -> bool
fn is_consumed(&self) -> bool
Returns
true
if the reader is finished producing dataSource§fn skip_until(&mut self, offset: VarInt) -> Result<(), Self::Error>
fn skip_until(&mut self, offset: VarInt) -> Result<(), Self::Error>
Skips the data in the reader until
offset
is reached, or the reader storage is exhausted.Source§fn with_max_data(&mut self, max_data: VarInt) -> Limit<'_, Self>
fn with_max_data(&mut self, max_data: VarInt) -> Limit<'_, Self>
Limits the maximum offset that the caller can read from the reader
Source§fn with_read_limit(&mut self, max_buffered_len: usize) -> Limit<'_, Self>
fn with_read_limit(&mut self, max_buffered_len: usize) -> Limit<'_, Self>
Limits the maximum amount of data that the caller can read from the reader
Source§fn with_empty_buffer(&self) -> Empty<'_, Self>
fn with_empty_buffer(&self) -> Empty<'_, Self>
Return an empty view onto the reader, with no change in current offset
Source§fn with_checks(&mut self) -> Checked<'_, Self>
fn with_checks(&mut self) -> Checked<'_, Self>
Enables checking the reader for correctness invariants Read more
Source§impl<R: Reader + ?Sized> Storage for Limit<'_, R>
impl<R: Reader + ?Sized> Storage for Limit<'_, R>
type Error = <R as Storage>::Error
Source§fn buffered_len(&self) -> usize
fn buffered_len(&self) -> usize
Returns the length of the chunk
Source§fn read_chunk(&mut self, watermark: usize) -> Result<Chunk<'_>, Self::Error>
fn read_chunk(&mut self, watermark: usize) -> Result<Chunk<'_>, Self::Error>
Reads the current contiguous chunk
Source§fn partial_copy_into<Dest>(
&mut self,
dest: &mut Dest,
) -> Result<Chunk<'_>, Self::Error>
fn partial_copy_into<Dest>( &mut self, dest: &mut Dest, ) -> Result<Chunk<'_>, Self::Error>
Copies the reader into
dest
, with a trailing chunk of bytes. Read moreSource§fn copy_into<Dest>(&mut self, dest: &mut Dest) -> Result<(), Self::Error>
fn copy_into<Dest>(&mut self, dest: &mut Dest) -> Result<(), Self::Error>
Copies the reader into
dest
. Read moreSource§fn buffer_is_empty(&self) -> bool
fn buffer_is_empty(&self) -> bool
Returns if the chunk is empty
Source§fn full_copy(&mut self) -> FullCopy<'_, Self>
fn full_copy(&mut self) -> FullCopy<'_, Self>
Forces the entire reader to be copied, even when calling
partial_copy_into
. Read moreSource§fn track_read(&mut self) -> Tracked<'_, Self>
fn track_read(&mut self) -> Tracked<'_, Self>
Tracks the number of bytes read from the storage
Auto Trait Implementations§
impl<'a, R> Freeze for Limit<'a, R>where
R: ?Sized,
impl<'a, R> RefUnwindSafe for Limit<'a, R>where
R: RefUnwindSafe + ?Sized,
impl<'a, R> Send for Limit<'a, R>
impl<'a, R> Sync for Limit<'a, R>
impl<'a, R> Unpin for Limit<'a, R>where
R: ?Sized,
impl<'a, R> !UnwindSafe for Limit<'a, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more