1use core::fmt;
4
5#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
6#[derive(strum::EnumString, strum::Display, strum::IntoStaticStr, strum::EnumIter)]
7pub enum LibTimeUnit {
8 #[strum(serialize = "1ps")]
10 _1ps,
11 #[strum(serialize = "10ps")]
13 _10ps,
14 #[strum(serialize = "100ps")]
16 _100ps,
17 #[default]
19 #[strum(serialize = "1ns")]
20 _1ns,
21}
22
23impl LibTimeUnit {
24 #[inline]
25 #[must_use]
26 pub const fn value(&self) -> f64 {
27 match self {
28 Self::_1ps => 1E-12_f64,
29 Self::_10ps => 1E-11_f64,
30 Self::_100ps => 1E-10_f64,
31 Self::_1ns => 1E-9_f64,
32 }
33 }
34}
35
36#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
37#[derive(strum::EnumString, strum::Display, strum::IntoStaticStr, strum::EnumIter)]
38pub enum LibVoltageUnit {
39 #[strum(serialize = "1mV")]
41 _1mV,
42 #[strum(serialize = "10mV")]
44 _10mV,
45 #[strum(serialize = "100mV")]
47 _100mV,
48 #[default]
50 #[strum(serialize = "1V")]
51 _1V,
52}
53
54impl LibVoltageUnit {
55 #[inline]
56 #[must_use]
57 pub const fn value(&self) -> f64 {
58 match self {
59 Self::_1mV => 1E-3_f64,
60 Self::_10mV => 1E-2_f64,
61 Self::_100mV => 1E-1_f64,
62 Self::_1V => 1E0_f64,
63 }
64 }
65}
66
67#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
68#[derive(strum::EnumString, strum::Display, strum::IntoStaticStr, strum::EnumIter)]
69pub enum LibCurrentUnit {
70 #[strum(serialize = "1uA")]
72 _1uA,
73 #[strum(serialize = "10uA")]
75 _10uA,
76 #[strum(serialize = "100uA")]
78 _100uA,
79 #[strum(serialize = "1mA")]
81 _1mA,
82 #[strum(serialize = "10mA")]
84 _10mA,
85 #[strum(serialize = "100mA")]
87 _100mA,
88 #[strum(serialize = "1A")]
90 _1A,
91}
92
93impl LibCurrentUnit {
94 #[inline]
95 #[must_use]
96 pub const fn value(&self) -> f64 {
97 match self {
98 Self::_1uA => 1E-6_f64,
99 Self::_10uA => 1E-5_f64,
100 Self::_100uA => 1E-4_f64,
101 Self::_1mA => 1E-3_f64,
102 Self::_10mA => 1E-2_f64,
103 Self::_100mA => 1E-1_f64,
104 Self::_1A => 1E0_f64,
105 }
106 }
107}
108
109#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
110#[derive(strum::EnumString, strum::Display, strum::IntoStaticStr, strum::EnumIter)]
111pub enum LibPullingResistanceUnit {
112 #[strum(serialize = "1ohm")]
114 _1ohm,
115 #[strum(serialize = "10ohm")]
117 _10ohm,
118 #[strum(serialize = "100ohm")]
120 _100ohm,
121 #[strum(serialize = "1kohm")]
123 _1kohm,
124}
125
126impl LibPullingResistanceUnit {
127 #[inline]
128 #[must_use]
129 pub const fn value(&self) -> f64 {
130 match self {
131 Self::_1ohm => 1E0_f64,
132 Self::_10ohm => 1E1_f64,
133 Self::_100ohm => 1E2_f64,
134 Self::_1kohm => 1E3_f64,
135 }
136 }
137}
138
139#[derive(Debug, Clone, Copy)]
140pub enum LibCapacitiveLoadUnit {
141 FF(f64),
142 PF(f64),
143}
144
145impl Default for LibCapacitiveLoadUnit {
146 #[inline]
147 fn default() -> Self {
148 Self::_1pf
149 }
150}
151
152impl fmt::Display for LibCapacitiveLoadUnit {
153 #[inline]
154 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
155 match self {
156 Self::FF(val) => write!(f, "{val} ff"),
157 Self::PF(val) => write!(f, "{val} pf"),
158 }
159 }
160}
161
162impl LibCapacitiveLoadUnit {
163 #[expect(non_upper_case_globals)]
164 pub const _1pf: Self = Self::PF(1.0);
165 #[expect(non_upper_case_globals)]
166 pub const _1ff: Self = Self::FF(1.0);
167 #[inline]
168 #[must_use]
169 #[expect(clippy::float_arithmetic)]
170 pub fn value(&self) -> f64 {
171 match self {
172 Self::FF(val) => val * 1e-15,
173 Self::PF(val) => val * 1e-12,
174 }
175 }
176}
177
178#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
179#[derive(strum::EnumString, strum::Display, strum::IntoStaticStr, strum::EnumIter)]
180pub enum LibLeakagePowerUnit {
181 #[strum(serialize = "1pW")]
183 _1pW,
184 #[strum(serialize = "10pW")]
186 _10pW,
187 #[strum(serialize = "100pW")]
189 _100pW,
190 #[strum(serialize = "1nW")]
192 _1nW,
193 #[strum(serialize = "10nW")]
195 _10nW,
196 #[strum(serialize = "100nW")]
198 _100nW,
199 #[strum(serialize = "1uW")]
201 _1uW,
202 #[strum(serialize = "10uW")]
204 _10uW,
205 #[strum(serialize = "100uW")]
207 _100uW,
208 #[strum(serialize = "1mW")]
210 _1mW,
211 #[strum(serialize = "10mW")]
213 _10mW,
214 #[strum(serialize = "100mW")]
216 _100mW,
217 #[strum(serialize = "1W")]
219 _1W,
220}
221
222impl LibLeakagePowerUnit {
223 #[inline]
224 #[must_use]
225 pub const fn value(&self) -> f64 {
226 match self {
227 Self::_1pW => 1E-12_f64,
228 Self::_10pW => 1E-11_f64,
229 Self::_100pW => 1E-10_f64,
230 Self::_1nW => 1E-9_f64,
231 Self::_10nW => 1E-8_f64,
232 Self::_100nW => 1E-7_f64,
233 Self::_1uW => 1E-6_f64,
234 Self::_10uW => 1E-5_f64,
235 Self::_100uW => 1E-4_f64,
236 Self::_1mW => 1E-3_f64,
237 Self::_10mW => 1E-2_f64,
238 Self::_100mW => 1E-1_f64,
239 Self::_1W => 1E-0_f64,
240 }
241 }
242}