FnMutChunkSource

Struct FnMutChunkSource 

Source
pub struct FnMutChunkSource<'s, F, B, E>
where F: FnMut() -> Option<Result<B, E>>, B: AsRef<[u8]> + 's,
{ /* private fields */ }
Expand description

A ChunkSource implementation that wraps a mutable closure (FnMut).

This struct is generic over a lifetime 's, the closure type F, the chunk type B, and the error type E. It correctly handles the lifetime of the returned chunks, which are guaranteed to live at least as long as the 's lifetime associated with the struct.

Implementations§

Source§

impl<'s, F, B, E> FnMutChunkSource<'s, F, B, E>
where F: FnMut() -> Option<Result<B, E>>, B: AsRef<[u8]> + 's,

Source

pub fn new(closure: F) -> Self

Creates a new FnMutChunkSource.

This function takes a closure F that will be used to generate chunks. The closure must return Option<Result<B, E>>, where B is a type that can be borrowed as a &[u8] and E is the error type.

Trait Implementations§

Source§

impl<'s, F, B, E> ChunkSource for FnMutChunkSource<'s, F, B, E>
where F: FnMut() -> Option<Result<B, E>>, B: AsRef<[u8]> + 's,

Source§

type Error = E

The type of error that can occur when reading a chunk.
Source§

type Chunk<'a> = B where Self: 'a

The type of chunk returned, which must implement AsRef<u8>
Source§

fn next_chunk<'a>(&'a mut self) -> Option<Result<Self::Chunk<'a>, Self::Error>>

Get the next chunk of bytes. Read more

Auto Trait Implementations§

§

impl<'s, F, B, E> Freeze for FnMutChunkSource<'s, F, B, E>
where F: Freeze,

§

impl<'s, F, B, E> RefUnwindSafe for FnMutChunkSource<'s, F, B, E>
where F: RefUnwindSafe,

§

impl<'s, F, B, E> Send for FnMutChunkSource<'s, F, B, E>
where F: Send,

§

impl<'s, F, B, E> Sync for FnMutChunkSource<'s, F, B, E>
where F: Sync,

§

impl<'s, F, B, E> Unpin for FnMutChunkSource<'s, F, B, E>
where F: Unpin,

§

impl<'s, F, B, E> UnwindSafe for FnMutChunkSource<'s, F, B, E>
where F: 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> 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, 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.