osom_lib_arrays/
errors.rs1use osom_lib_primitives::length::LengthError;
3use osom_lib_reprc::macros::reprc;
4
5#[reprc]
8#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
9#[must_use]
10pub enum ArrayError {
11 AllocationError = 0,
14
15 LengthLimitExceeded = 1,
17}
18
19impl core::fmt::Display for ArrayError {
20 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
21 match self {
22 ArrayError::AllocationError => write!(f, "ArrayError::AllocationError"),
23 ArrayError::LengthLimitExceeded => write!(f, "ArrayError::LengthLimitExceeded"),
24 }
25 }
26}
27
28impl From<LengthError> for ArrayError {
29 fn from(_: LengthError) -> Self {
30 Self::LengthLimitExceeded
31 }
32}
33
34osom_lib_macros::unreachable_from_infallible!(ArrayError);
35
36#[reprc]
37#[repr(u8)]
38#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
39#[must_use]
40pub enum ArrayTryCloneError {
41 ArrayError(ArrayError) = 0,
44
45 ItemCloningError = 1,
47}
48
49osom_lib_macros::unreachable_from_infallible!(ArrayTryCloneError);
50
51impl core::fmt::Display for ArrayTryCloneError {
52 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
53 match self {
54 ArrayTryCloneError::ArrayError(err) => write!(f, "ArrayError::ArrayError({err})"),
55 ArrayTryCloneError::ItemCloningError => write!(f, "ArrayError::ItemCloningError"),
56 }
57 }
58}
59
60impl From<ArrayError> for ArrayTryCloneError {
61 fn from(err: ArrayError) -> Self {
62 Self::ArrayError(err)
63 }
64}
65
66#[reprc]
68#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
69#[must_use]
70pub struct ArrayIsEmptyError;
71
72osom_lib_macros::unreachable_from_infallible!(ArrayIsEmptyError);
73
74impl core::fmt::Display for ArrayIsEmptyError {
75 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
76 write!(f, "ArrayIsEmptyError")
77 }
78}