1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5#[non_exhaustive]
6pub enum InstrumentKind {
7 Dmm,
8 DcPowerSupply,
9 FunctionGenerator,
10 Unknown,
11}
12
13impl InstrumentKind {
14 pub fn from_str_label(label: &str) -> Option<Self> {
15 match label {
16 "Dmm" => Some(Self::Dmm),
17 "DcPowerSupply" => Some(Self::DcPowerSupply),
18 "FunctionGenerator" => Some(Self::FunctionGenerator),
19 "Unknown" => Some(Self::Unknown),
20 _ => None,
21 }
22 }
23
24 pub fn as_str(self) -> &'static str {
25 match self {
26 Self::Dmm => "Dmm",
27 Self::DcPowerSupply => "DcPowerSupply",
28 Self::FunctionGenerator => "FunctionGenerator",
29 Self::Unknown => "Unknown",
30 }
31 }
32}
33
34impl std::fmt::Display for InstrumentKind {
35 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 write!(f, "{}", self.as_str())
37 }
38}