Struct iroh_blobs::util::progress::FallibleProgressSliceWriter
source · pub struct FallibleProgressSliceWriter<W, F>(/* private fields */);
Expand description
A slice writer that adds a fallible progress callback.
This wraps any AsyncSliceWriter
, passes through all operations to the inner writer, and
calls the passed on_write
callback whenever data is written. on_write
must return an
io::Result
, and can abort the download by returning an error.
Implementations§
source§impl<W: AsyncSliceWriter, F: Fn(u64, usize) -> Result<()> + 'static> FallibleProgressSliceWriter<W, F>
impl<W: AsyncSliceWriter, F: Fn(u64, usize) -> Result<()> + 'static> FallibleProgressSliceWriter<W, F>
sourcepub fn new(inner: W, on_write: F) -> Self
pub fn new(inner: W, on_write: F) -> Self
Create a new ProgressSliceWriter
from an inner writer and a progress callback
The on_write
function is called for each write, with the offset
as the first and the
length of the data as the second param. on_write
must return a future which resolves to
an io::Result
. If on_write
returns an error, the download is aborted.
sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Return the inner writer.
Trait Implementations§
source§impl<W: AsyncSliceWriter + 'static, F: Fn(u64, usize) -> Result<()> + 'static> AsyncSliceWriter for FallibleProgressSliceWriter<W, F>
impl<W: AsyncSliceWriter + 'static, F: Fn(u64, usize) -> Result<()> + 'static> AsyncSliceWriter for FallibleProgressSliceWriter<W, F>
Auto Trait Implementations§
impl<W, F> Freeze for FallibleProgressSliceWriter<W, F>
impl<W, F> RefUnwindSafe for FallibleProgressSliceWriter<W, F>where
W: RefUnwindSafe,
F: RefUnwindSafe,
impl<W, F> Send for FallibleProgressSliceWriter<W, F>
impl<W, F> Sync for FallibleProgressSliceWriter<W, F>
impl<W, F> Unpin for FallibleProgressSliceWriter<W, F>
impl<W, F> UnwindSafe for FallibleProgressSliceWriter<W, F>where
W: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more