diff options
| author | diogo464 <[email protected]> | 2025-12-04 11:51:07 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-04 11:51:07 +0000 |
| commit | 3289c2d9f6257f68cbdd37b78e5e79a41e9e33a1 (patch) | |
| tree | b6316df529e56a65e914e982e3c2981605e7a43c /src/unit.rs | |
init
Diffstat (limited to 'src/unit.rs')
| -rw-r--r-- | src/unit.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/unit.rs b/src/unit.rs new file mode 100644 index 0000000..4f3ca19 --- /dev/null +++ b/src/unit.rs | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 2 | pub enum TemperatureUnit { | ||
| 3 | Celcius, | ||
| 4 | Kelvin, | ||
| 5 | Fahrenheit, | ||
| 6 | Other(&'static str), | ||
| 7 | } | ||
| 8 | |||
| 9 | impl TemperatureUnit { | ||
| 10 | pub fn as_str(&self) -> &'static str { | ||
| 11 | // TODO: improve | ||
| 12 | match self { | ||
| 13 | TemperatureUnit::Celcius => "C", | ||
| 14 | TemperatureUnit::Kelvin => "k", | ||
| 15 | TemperatureUnit::Fahrenheit => "F", | ||
| 16 | TemperatureUnit::Other(other) => other, | ||
| 17 | } | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 22 | pub enum HumidityUnit { | ||
| 23 | Percentage, | ||
| 24 | Other(&'static str), | ||
| 25 | } | ||
| 26 | |||
| 27 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 28 | pub enum BatteryUnit { | ||
| 29 | Percentage, | ||
| 30 | } | ||
| 31 | |||
| 32 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 33 | pub enum LightUnit { | ||
| 34 | Lux, | ||
| 35 | } | ||
| 36 | |||
| 37 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 38 | pub enum PressureUnit { | ||
| 39 | HectoPascal, | ||
| 40 | } | ||
| 41 | |||
| 42 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 43 | pub enum EnergyUnit { | ||
| 44 | KiloWattHour, | ||
| 45 | } | ||
