Skip to main content

MemoryError

Enum MemoryError 

Source
pub enum MemoryError {
    TierExhausted {
        tier: &'static str,
        requested: u64,
        used: u64,
        limit: u64,
        available: u64,
        role: MemoryRole,
    },
    InvalidRequest {
        tier: &'static str,
        requested: u64,
        reason: &'static str,
    },
    AllocationFailed {
        tier: &'static str,
        requested: u64,
        reason: String,
    },
    CapacityUnavailable {
        tier: &'static str,
        requested: u64,
        available: u64,
        role: MemoryRole,
        detail: String,
        source: Option<Box<dyn Error + Send + Sync>>,
    },
}
Expand description

Shared error vocabulary for mechanism and governance operations.

Not Clone/PartialEq: a refusal that carries the cause underneath it cannot be meaningfully duplicated or compared, and keeping the cause is worth more than either. Match on the variant instead.

Variants§

§

TierExhausted

The tier does not have room, and no holder released enough.

Fields

§tier: &'static str

Which tier ran out.

§requested: u64

What the caller asked for.

§used: u64

Bytes leased before this request.

§limit: u64

The tier ceiling.

§available: u64

limit - used.

§role: MemoryRole

The role that was refused.

§

InvalidRequest

The request itself is not representable.

Fields

§tier: &'static str

Which tier was addressed.

§requested: u64

What the caller asked for.

§reason: &'static str

What is wrong with it.

§

AllocationFailed

The request was well formed and within budget, but the allocator behind the tier refused it for a reason of its own.

Distinct from MemoryError::TierExhausted, which means we declined, and from MemoryError::InvalidRequest, which means the caller asked for something impossible. This one carries the backing allocator’s own account of the failure, which is usually the only thing that identifies it: a driver that is out of memory and a driver that has no context both fail an allocation, and calling them both “out of memory” sends the next person to read the log in the wrong direction.

Fields

§tier: &'static str

Which tier was addressed.

§requested: u64

What the caller asked for.

§reason: String

What the backing allocator said.

§

CapacityUnavailable

A well-formed capacity transfer or backing claim could not make enough governed bytes available.

Fields

§tier: &'static str
§requested: u64
§available: u64
§detail: String

What this layer can say about the shortfall on its own.

Names the operation that came up short; the refusal underneath it, when there was one, belongs in source rather than being folded in here, so that a caller can still match on it and a reader is not shown the same sentence twice.

§source: Option<Box<dyn Error + Send + Sync>>

The refusal this one is reporting, when it is reporting one.

None when this layer decided on its own, as when a reclaim target simply was not reached. Typed as dyn Error rather than a boxed MemoryError both because the layer underneath is not always a governor and because #[source] on a Box<ConcreteError> hands callers a chain node whose concrete type is the box, so downcast_ref::<MemoryError>() would miss it – which is the whole thing this field exists to make possible.

Trait Implementations§

Source§

impl Debug for MemoryError

Source§

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

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

impl Display for MemoryError

Source§

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

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

impl Error for MemoryError

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 From<MemoryError> for BindingError

Source§

fn from(source: MemoryError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> BindingResource for T
where T: Send + Sync + Debug,

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.