Interposer

Struct Interposer 

Source
pub struct Interposer<'a, S, D>
where S: Storage + ?Sized, D: Skip<Error = Infallible> + ?Sized,
{ /* private fields */ }
Expand description

A wrapper around an underlying buffer (duplex) which will prefer to read/write from a user-provided temporary buffer (storage). The underlying buffer (duplex)’s current position and total length are updated if needed.

Implementations§

Source§

impl<'a, S, D> Interposer<'a, S, D>
where S: Storage + ?Sized, D: Skip<Error = Infallible> + ?Sized,

Source

pub fn new(storage: &'a mut S, duplex: &'a mut D) -> Self

Trait Implementations§

Source§

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

Delegates to the inner Duplex

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
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 Read more
Source§

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

Delegates to the inner Duplex

Source§

type Error = <D as Storage>::Error

Source§

fn buffered_len(&self) -> usize

Returns the length of the chunk
Source§

fn buffer_is_empty(&self) -> bool

Returns if the chunk is empty
Source§

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>
where Dest: Storage + ?Sized,

Copies the reader into dest, with a trailing chunk of bytes. Read more
Source§

fn copy_into<Dest>(&mut self, dest: &mut Dest) -> Result<(), Self::Error>
where Dest: Storage + ?Sized,

Copies the reader into dest. Read more
Source§

fn full_copy(&mut self) -> FullCopy<'_, Self>

Forces the entire reader to be copied, even when calling partial_copy_into. Read more
Source§

fn track_read(&mut self) -> Tracked<'_, Self>

Tracks the number of bytes read from the storage
Source§

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

Source§

fn read_from<R>(&mut self, reader: &mut R) -> Result<(), Error<R::Error>>
where R: Reader + ?Sized,

Auto Trait Implementations§

§

impl<'a, S, D> Freeze for Interposer<'a, S, D>
where S: ?Sized, D: ?Sized,

§

impl<'a, S, D> RefUnwindSafe for Interposer<'a, S, D>

§

impl<'a, S, D> Send for Interposer<'a, S, D>
where S: Send + ?Sized, D: Send + ?Sized,

§

impl<'a, S, D> Sync for Interposer<'a, S, D>
where S: Sync + ?Sized, D: Sync + ?Sized,

§

impl<'a, S, D> Unpin for Interposer<'a, S, D>
where S: ?Sized, D: ?Sized,

§

impl<'a, S, D> !UnwindSafe for Interposer<'a, S, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Infallible for T
where T: Storage<Error = Infallible> + ?Sized,

Source§

fn infallible_read_chunk(&mut self, watermark: usize) -> Chunk<'_>

Source§

fn infallible_partial_copy_into<Dest>(&mut self, dest: &mut Dest) -> Chunk<'_>
where Dest: Storage + ?Sized,

Source§

fn infallible_copy_into<Dest>(&mut self, dest: &mut Dest)
where Dest: Storage + ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T

Source§

impl<T> Duplex for T
where T: Reader + Writer,