Skip to main content

TransferLimitError

Enum TransferLimitError 

Source
pub enum TransferLimitError<E, C = usize> {
    LimitExceeded {
        limit: C,
        actual: C,
    },
    CounterOverflow {
        bytes_seen: C,
        chunk_len: usize,
    },
    Inner {
        source: E,
    },
}
Expand description

Error returned by a transfer-limited stream.

Variants§

§

LimitExceeded

The stream produced more bytes than allowed.

Fields

§limit: C

Configured maximum number of bytes.

§actual: C

Number of bytes observed after reading the chunk that crossed the limit.

§

CounterOverflow

The cumulative byte count cannot be represented by the selected counter.

Fields

§bytes_seen: C

Number of bytes counted before reading the chunk that overflowed.

§chunk_len: usize

Byte length of the chunk that could not be added to the counter.

§

Inner

The wrapped stream returned an error.

Fields

§source: E

Original stream error.

Implementations§

Source§

impl<E, C> TransferLimitError<E, C>

Source

pub fn is_limit_exceeded(&self) -> bool

Returns true when this error represents an exceeded transfer limit.

Source

pub fn is_counter_overflow(&self) -> bool

Returns true when the selected counter type could not represent the cumulative byte count.

Source

pub fn into_inner(self) -> Option<E>

Returns the wrapped stream error, if this is an inner stream error.

Trait Implementations§

Source§

impl<E: Debug, C: Debug> Debug for TransferLimitError<E, C>

Source§

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

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

impl<E, C> Display for TransferLimitError<E, C>
where C: Display,

Source§

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

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

impl<E, C> Error for TransferLimitError<E, C>
where E: Error + 'static, Self: Debug + Display,

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<E, C> From<E> for TransferLimitError<E, C>

Source§

fn from(source: E) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<E, C> Freeze for TransferLimitError<E, C>
where C: Freeze, E: Freeze,

§

impl<E, C> RefUnwindSafe for TransferLimitError<E, C>

§

impl<E, C> Send for TransferLimitError<E, C>
where C: Send, E: Send,

§

impl<E, C> Sync for TransferLimitError<E, C>
where C: Sync, E: Sync,

§

impl<E, C> Unpin for TransferLimitError<E, C>
where C: Unpin, E: Unpin,

§

impl<E, C> UnsafeUnpin for TransferLimitError<E, C>
where C: UnsafeUnpin, E: UnsafeUnpin,

§

impl<E, C> UnwindSafe for TransferLimitError<E, C>
where C: UnwindSafe, E: 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<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.