osom_lib_hash_tables/
errors.rs1use osom_lib_reprc::macros::reprc;
3
4#[reprc]
7#[repr(u8)]
8#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
9#[must_use]
10pub enum HashTableError {
11 AllocationError = 0,
14
15 LengthLimitExceeded = 1,
17
18 AllocatorCloningError = 2,
20}
21
22osom_lib_macros::unreachable_from_infallible!(HashTableError);
23
24impl core::fmt::Display for HashTableError {
25 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26 match self {
27 HashTableError::AllocationError => write!(f, "HashTableError::AllocationError"),
28 HashTableError::LengthLimitExceeded => write!(f, "HashTableError::LengthLimitExceeded"),
29 HashTableError::AllocatorCloningError => write!(f, "HashTableError::AllocatorCloningError"),
30 }
31 }
32}
33
34#[reprc]
36#[repr(u8)]
37#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
38#[must_use]
39pub enum TryCloneHashTableError {
40 HashTableError(HashTableError) = 0,
42
43 KeyOrValueError = 1,
45}
46
47osom_lib_macros::unreachable_from_infallible!(TryCloneHashTableError);
48
49impl From<HashTableError> for TryCloneHashTableError {
50 fn from(error: HashTableError) -> Self {
51 Self::HashTableError(error)
52 }
53}
54
55impl core::fmt::Display for TryCloneHashTableError {
56 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
57 match self {
58 TryCloneHashTableError::HashTableError(error) => {
59 write!(f, "TryCloneHashTableError::HashTableError({error})")
60 }
61 TryCloneHashTableError::KeyOrValueError => write!(f, "TryCloneHashTableError::KeyOrValueError"),
62 }
63 }
64}