1#![allow(clippy::module_name_repetitions)]
2
3use std::alloc::LayoutError;
4
5use thiserror::Error;
6
7#[derive(Debug, Error, PartialEq, Eq, Clone)]
8pub enum AllocationError {
9 #[error("An arithmetic error occured.")]
10 ArithmeticError,
11 #[error(transparent)]
12 LayoutError(#[from] LayoutError),
13 #[error("Process ran out of memory.")]
14 OutOfMemory,
15}
16
17#[derive(Debug, Error, PartialEq, Eq, Clone)]
18pub enum DeallocationError {
19 #[error("This memory was already freed.")]
20 DoubleFree,
21 #[error("The pointer provided was not properly aligned.")]
22 ImproperAlignment,
23 #[error("Tried to free memory not allocated by this crate.")]
24 InvalidAllocation,
25 #[error(transparent)]
26 LayoutError(#[from] LayoutError),
27 #[error("Tried to free a null pointer.")]
28 NullPtr,
29}