Reader

Trait Reader 

Source
pub trait Reader: Storage {
    // Required methods
    fn current_offset(&self) -> VarInt;
    fn final_offset(&self) -> Option<VarInt>;

    // Provided methods
    fn has_buffered_fin(&self) -> bool { ... }
    fn is_consumed(&self) -> bool { ... }
    fn skip_until(&mut self, offset: VarInt) -> Result<(), Self::Error> { ... }
    fn with_max_data(&mut self, max_data: VarInt) -> Limit<'_, Self> { ... }
    fn with_read_limit(&mut self, max_buffered_len: usize) -> Limit<'_, Self> { ... }
    fn with_empty_buffer(&self) -> Empty<'_, Self> { ... }
    fn with_checks(&mut self) -> Checked<'_, Self> { ... }
}
Expand description

A buffer that can be read with a tracked offset and final position.

Required Methods§

Source

fn current_offset(&self) -> VarInt

Returns the currently read offset for the stream

Source

fn final_offset(&self) -> Option<VarInt>

Returns the final offset for the stream

Provided Methods§

Source

fn has_buffered_fin(&self) -> bool

Returns true if the reader has the final offset buffered

Source

fn is_consumed(&self) -> bool

Returns true if the reader is finished producing data

Source

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>

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>

Limits the maximum amount of data that the caller can read from the reader

Source

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>

Enables checking the reader for correctness invariants

§Note

debug_assertions must be enabled for these checks to be performed. Otherwise, the reader methods will simply be forwarded to Self.

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.

Implementors§

Source§

impl Reader for Reassembler

Source§

impl<C> Reader for Complete<'_, C>
where C: Storage,

Source§

impl<C, D> Reader for Interposer<'_, C, D>
where C: Storage + ?Sized, D: Skip<Error = Infallible> + ?Sized,

Delegates to the inner Duplex

Source§

impl<C: Storage> Reader for WithStorage<'_, C>

Source§

impl<R> Reader for Checked<'_, R>
where R: Reader + ?Sized,

Source§

impl<R: Reader + ?Sized> Reader for Empty<'_, R>

Source§

impl<R: Reader + ?Sized> Reader for Limit<'_, R>

Source§

impl<S: Reader + ?Sized> Reader for Tracked<'_, S>