Struct BufferedLoader

Source
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.

Source§

type Error = <Loader as Load>::Error

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 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> ToOwned for T
where T: Clone,

Source§

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 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.