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
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
RemoveWhileValueReferenced(usize)
Indicates that the last element in the Prisonremove()
-ing the value
from the underlying Vec
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
impl AccessError
Sourcepub fn kind(&self) -> String
pub fn kind(&self) -> String
Returns a string that shows the AccessError variant and value, if any