molframe_core/limits/
storage.rs1use std::fmt;
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub struct CapacityError {
8 resource: &'static str,
9}
10
11impl CapacityError {
12 #[must_use]
14 pub const fn new(resource: &'static str) -> Self {
15 Self { resource }
16 }
17
18 #[must_use]
20 pub const fn resource(self) -> &'static str {
21 self.resource
22 }
23}
24
25impl fmt::Display for CapacityError {
26 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
27 write!(
28 formatter,
29 "{} exceeds its supported capacity",
30 self.resource
31 )
32 }
33}
34
35impl std::error::Error for CapacityError {}
36
37#[derive(Clone, Copy, Debug, PartialEq, Eq)]
39pub enum TableError {
40 Capacity(CapacityError),
42 ReversedRange {
44 table: &'static str,
46 },
47 MissingIndex {
49 table: &'static str,
51 },
52}
53
54impl fmt::Display for TableError {
55 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
56 match self {
57 Self::Capacity(error) => error.fmt(formatter),
58 Self::ReversedRange { table } => write!(formatter, "{table} child range is reversed"),
59 Self::MissingIndex { table } => write!(formatter, "{table} index does not exist"),
60 }
61 }
62}
63
64impl std::error::Error for TableError {}