pub struct BufferedLoader<Buffer, Loader>where
    Buffer: AsRef<[u8]> + AsMut<[u8]> + Debug,
    Loader: Load,{ /* private fields */ }
Expand description

A buffering wrapper around a Load.

This fills some of the simpler niches of a std::io::BufReader for no_std use-cases, and allowing a static buffer.

Implementations§

source§

impl<const N: usize, Loader> BufferedLoader<[u8; N], Loader>where Loader: Load,

source

pub fn new_static(loader: Loader) -> Self

Creates a new stack-based BufferedLoader. Does not allocate.

source§

impl<Loader> BufferedLoader<Vec<u8>, Loader>where Loader: Load,

source

pub fn new_dynamic(loader: Loader, buffer_size: usize) -> Self

Creates a new heap-based BufferedLoader. Allocates only once.

source

pub fn resize(&mut self, new_size: usize)

source§

impl<Loader> BufferedLoader<Box<[u8]>, Loader>where Loader: Load,

source

pub fn new_heap(loader: Loader, buffer_size: usize) -> Self

Creates a new heap-based BufferedLoader. Allocates only once.

source§

impl<Buffer, Loader> BufferedLoader<Buffer, Loader>where Buffer: AsRef<[u8]> + AsMut<[u8]> + Debug, Loader: Load,

source

pub fn new(buffer: Buffer, loader: Loader) -> Self

source

pub fn loader(&mut self) -> &mut Loader

Drop what’s remaining in the buffer and give a mutable reference to the inner loader, so it can be seeked or otherwise manipulated.

Trait Implementations§

source§

impl<Buffer, Loader> Clone for BufferedLoader<Buffer, Loader>where Buffer: AsRef<[u8]> + AsMut<[u8]> + Debug + Clone, Loader: Load + Clone,

source§

fn clone(&self) -> BufferedLoader<Buffer, Loader>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Buffer, Loader> Debug for BufferedLoader<Buffer, Loader>where Buffer: AsRef<[u8]> + AsMut<[u8]> + Debug + Debug, Loader: Load + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Buffer, Loader> Load for BufferedLoader<Buffer, Loader>where Buffer: AsRef<[u8]> + AsMut<[u8]> + Debug, Loader: Load,

source§

fn load(&mut self, destination: &mut [u8]) -> Result<(), Self::Error>

Efficiently fill the destination buffer, calling the underlying Load::load as few times as possible.

§

type Error = <Loader as Load>::Error

Auto Trait Implementations§

§

impl<Buffer, Loader> RefUnwindSafe for BufferedLoader<Buffer, Loader>where Buffer: RefUnwindSafe, Loader: RefUnwindSafe,

§

impl<Buffer, Loader> Send for BufferedLoader<Buffer, Loader>where Buffer: Send, Loader: Send,

§

impl<Buffer, Loader> Sync for BufferedLoader<Buffer, Loader>where Buffer: Sync, Loader: Sync,

§

impl<Buffer, Loader> Unpin for BufferedLoader<Buffer, Loader>where Buffer: Unpin, Loader: Unpin,

§

impl<Buffer, Loader> UnwindSafe for BufferedLoader<Buffer, Loader>where Buffer: UnwindSafe, Loader: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.