ps_alloc/
error.rs

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("The allocated memory was not properly aligned.")]
12    ImproperAlignment,
13    #[error(transparent)]
14    LayoutError(#[from] LayoutError),
15    #[error("Process ran out of memory.")]
16    OutOfMemory,
17}
18
19#[derive(Debug, Error, PartialEq, Eq, Clone)]
20pub enum DeallocationError {
21    #[error("This memory was already freed.")]
22    DoubleFree,
23    #[error("The pointer provided was not properly aligned.")]
24    ImproperAlignment,
25    #[error("Tried to free memory not allocated by this crate.")]
26    InvalidAllocation,
27    #[error(transparent)]
28    LayoutError(#[from] LayoutError),
29    #[error("Tried to free a null pointer.")]
30    NullPtr,
31}