1
2use std::ops::Deref;
3use std::ops::DerefMut;
4
5#[derive(Debug, Clone, PartialEq, PartialOrd)]
6pub enum StaticInitErr {
7 PrevLock,
8 AllowLock,
9 UnkState,
10}
11
12impl StaticInitErr {
13 #[inline]
14 pub const fn prev() -> Self {
15 StaticInitErr::PrevLock
16 }
17
18 #[inline]
19 pub const fn allow() -> Self {
20 StaticInitErr::AllowLock
21 }
22
23 #[inline]
24 pub const fn unk() -> Self {
25 StaticInitErr::UnkState
26 }
27}
28
29
30#[derive(Debug, Clone, PartialEq, PartialOrd)]
31pub enum IgnoreInitErr {
32 PrevLock,
33 AllowLock,
34}
35
36impl IgnoreInitErr {
37 #[inline]
38 pub const fn prev() -> Self {
39 IgnoreInitErr::PrevLock
40 }
41
42 #[inline]
43 pub const fn allow() -> Self {
44 IgnoreInitErr::AllowLock
45 }
46}
47
48
49
50#[derive(Debug, Clone, PartialEq, PartialOrd)]
51pub struct StaticErr<T> {
52 data: T,
53 r#type: StaticInitErr,
54}
55
56impl<T> From<T> for StaticErr<T> {
57 #[inline(always)]
58 fn from(a: T) -> Self {
59 Self::unk(a)
60 }
61}
62
63impl<T> StaticErr<T> {
64 #[inline]
65 pub const fn new(arg: T, err: StaticInitErr) -> Self {
66 Self {
67 data: arg,
68 r#type: err,
69 }
70 }
71
72 #[inline]
73 pub const fn prev(arg: T) -> Self {
74 Self::new(arg, StaticInitErr::prev())
75 }
76
77 #[inline]
78 pub const fn allow(arg: T) -> Self {
79 Self::new(arg, StaticInitErr::allow())
80 }
81
82 #[inline]
83 pub const fn unk(arg: T) -> Self {
84 Self::new(arg, StaticInitErr::unk())
85 }
86
87 #[inline]
88 pub fn into_inner(self) -> T {
89 self.data
90 }
91
92 #[inline]
93 pub fn into_type(self) -> StaticInitErr {
94 self.r#type
95 }
96
97 #[inline(always)]
98 pub const fn as_type(&self) -> &StaticInitErr {
99 &self.r#type
100 }
101
102 #[inline(always)]
103 pub const fn as_inner(&self) -> &T {
104 &self.data
105 }
106}
107
108
109impl<T> From<(T, StaticInitErr)> for StaticErr<T> {
110 #[inline(always)]
111 fn from((v, t): (T, StaticInitErr)) -> Self {
112 Self::new(v, t)
113 }
114}
115
116impl<T> Deref for StaticErr<T> {
117 type Target = StaticInitErr;
118
119 #[inline(always)]
120 fn deref(&self) -> &Self::Target {
121 &self.r#type
122 }
123}
124
125impl<T> DerefMut for StaticErr<T> {
126 #[inline(always)]
127 fn deref_mut(&mut self) -> &mut Self::Target {
128 &mut self.r#type
129 }
130}