Enum AccessError

Source
pub enum AccessError {
    IndexOutOfRange(usize),
    ValueAlreadyMutablyReferenced(usize),
    ValueStillImmutablyReferenced(usize),
    OverwriteWhileValueReferenced(usize),
    InsertAtMaxCapacityWhileAValueIsReferenced,
    RemoveWhileValueReferenced(usize),
    ValueDeleted(usize, usize),
    MaxValueForGenerationReached,
    IndexIsNotFree(usize),
    MaximumCapacityReached,
    MaximumImmutableReferencesReached(usize),
    MAJOR_MALFUNCTION(String),
}
Expand description

Error type that provides helpful information about why an operation on any Prison or JailCell failed

Every error returned from functions or methods defined in this crate will be one of these variants, and all safe versions of Prison and JailCell are designed to never panic and always return errors.

Additional variants may be added in the future, therefore it is recommended you add a catch-all branch to any match statements on this enum to future-proof your code:

match acc_err {
    AccessError::IndexOutOfRange(bad_idx) => {},
    AccessError::ValueAlreadyMutablyReferenced(duplicate_idx) => {},
    // other variants
    _ => {}
}

AccessError has a custom implementation for both std::fmt::Display and std::fmt::Debug traits, with the Display version giving a short description of the problem, and the Debug version giving a more in-depth explaination of exactly why an error had to be returned

Variants§

§

IndexOutOfRange(usize)

Indicates that an operation attempted to access an index beyond the range of the Prison, along with the offending index

§

ValueAlreadyMutablyReferenced(usize)

Indicates that an operation attempted to reference a value (mutably or immutably) already being mutably referenced by another operation, along with the index in question

§

ValueStillImmutablyReferenced(usize)

Indicates that an operation attempted to mutably reference a value already being immutably referenced by another operation, along with the index in question

§

OverwriteWhileValueReferenced(usize)

Indicates that an overwriteing insert would invalidate currently active references to a value

§

InsertAtMaxCapacityWhileAValueIsReferenced

Indicates that an insert would require re-allocation of the internal Vec, thereby invalidating any currently active references

§

RemoveWhileValueReferenced(usize)

Indicates that the last element in the Prison is being accessed, and remove()-ing the value from the underlying Vec would invalidate the reference

§

ValueDeleted(usize, usize)

Indicates that the value requested was deleted and a new value with an updated generation took its place

Contains the index and generation from the invalid CellKey, in that order

§

MaxValueForGenerationReached

Indicates that a very large number of removes and inserts caused the generation counter to reach its max value

§

IndexIsNotFree(usize)

Indicates that an attempted insert to a specific index would overwrite and invalidate a value still in use

§

MaximumCapacityReached

Indicates that the underlying Vec reached the maximum capacity set by Rust (isize::MAX)

§

MaximumImmutableReferencesReached(usize)

Indicates that you (somehow) reached the limit for reference counting immutable references

§

MAJOR_MALFUNCTION(String)

Indicates that the operation created an invalid and unexpected state. This may have resulted in memory leaking, mutable aliasing, undefined behavior, etc.

This error should be considered a BUG inside the library crate grit-data-prison and reported to the author of the crate

Implementations§

Source§

impl AccessError

Source

pub fn kind(&self) -> String

Returns a string that shows the AccessError variant and value, if any

Trait Implementations§

Source§

impl Debug for AccessError

Source§

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

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

impl Display for AccessError

Source§

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

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

impl Error for AccessError

1.30.0 · 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 PartialEq for AccessError

Source§

fn eq(&self, other: &AccessError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for AccessError

Source§

impl StructuralPartialEq for AccessError

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