pub struct TransferLimit<C = usize, P = NoopProgress<C>> { /* private fields */ }Expand description
Builder for applying byte-count transfer limits to fallible streams.
Implementations§
Source§impl TransferLimit<usize, NoopProgress<usize>>
impl TransferLimit<usize, NoopProgress<usize>>
Source§impl<C> TransferLimit<C, NoopProgress<C>>where
C: TransferCounter,
impl<C> TransferLimit<C, NoopProgress<C>>where
C: TransferCounter,
Sourcepub fn from_limit(limit: C) -> Self
pub fn from_limit(limit: C) -> Self
Create a transfer limit using an explicit counter type.
Sourcepub fn from_optional_limit(limit: Option<C>) -> Self
pub fn from_optional_limit(limit: Option<C>) -> Self
Create a transfer limit from an optional byte limit using an explicit counter type.
Source§impl<C, P> TransferLimit<C, P>where
C: TransferCounter,
impl<C, P> TransferLimit<C, P>where
C: TransferCounter,
Sourcepub fn with_limit(self, limit: C) -> Self
pub fn with_limit(self, limit: C) -> Self
Set the maximum allowed number of bytes.
A stream is allowed to produce exactly limit bytes. It fails on the
first chunk that makes the cumulative total greater than limit.
Sourcepub fn without_limit(self) -> Self
pub fn without_limit(self) -> Self
Remove the maximum byte limit while keeping progress tracking.
Sourcepub fn on_progress<F>(self, on_progress: F) -> TransferLimit<C, F>where
F: FnMut(C),
pub fn on_progress<F>(self, on_progress: F) -> TransferLimit<C, F>where
F: FnMut(C),
Replace the progress callback.
The callback receives cumulative bytes after every successful chunk read from the inner stream, including the chunk that crosses the limit.
Trait Implementations§
Source§impl<C: Clone, P: Clone> Clone for TransferLimit<C, P>
impl<C: Clone, P: Clone> Clone for TransferLimit<C, P>
Source§fn clone(&self) -> TransferLimit<C, P>
fn clone(&self) -> TransferLimit<C, P>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<C> Default for TransferLimit<C, NoopProgress<C>>where
C: TransferCounter,
impl<C> Default for TransferLimit<C, NoopProgress<C>>where
C: TransferCounter,
Auto Trait Implementations§
impl<C, P> Freeze for TransferLimit<C, P>
impl<C, P> RefUnwindSafe for TransferLimit<C, P>where
C: RefUnwindSafe,
P: RefUnwindSafe,
impl<C, P> Send for TransferLimit<C, P>
impl<C, P> Sync for TransferLimit<C, P>
impl<C, P> Unpin for TransferLimit<C, P>
impl<C, P> UnsafeUnpin for TransferLimit<C, P>where
C: UnsafeUnpin,
P: UnsafeUnpin,
impl<C, P> UnwindSafe for TransferLimit<C, P>where
C: UnwindSafe,
P: UnwindSafe,
Blanket Implementations§
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