1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// @generated by openehr-codegen from BMM (`BMM_PARAMETER_DIRECTION`) — DO NOT EDIT.
//! The openEHR `BMM_PARAMETER_DIRECTION` spec class, generated from the vendored BMM
//! meta-model.
/// Enumeration of parameter read/write direction values.
#[doc(alias = "BMM_PARAMETER_DIRECTION")]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BmmParameterDirection {
/// `in`
In,
/// `out`
Out,
/// `in_out`
InOut,
/// A value outside the `BMM_PARAMETER_DIRECTION` constant set.
///
/// NOTE: no openEHR spec governs an out-of-set value — our own
/// tolerance-preserving design (`BMM_ENUMERATION` defines only the listed
/// constants), retained so this enum's wire form stays byte-identical to
/// the bare `String` it replaces.
Other(String),
}
impl BmmParameterDirection {
/// The wire string of this constant (the verbatim token for
/// [`Self::Other`]).
#[must_use]
pub fn as_str(&self) -> &str {
match self {
Self::In => "in",
Self::Out => "out",
Self::InOut => "in_out",
Self::Other(__s) => __s.as_str(),
}
}
/// This constant for a wire string, tolerating an unknown token
/// as [`Self::Other`] (total — never fails).
#[must_use]
pub fn from_wire(__s: &str) -> Self {
match __s {
"in" => Self::In,
"out" => Self::Out,
"in_out" => Self::InOut,
_ => Self::Other(__s.to_owned()),
}
}
}
impl ::core::convert::TryFrom<&str> for BmmParameterDirection {
type Error = UnknownBmmParameterDirection;
/// # Errors
/// Returns [`UnknownBmmParameterDirection`] when `__s` is not a `BMM_PARAMETER_DIRECTION` value
/// (unlike [`Self::from_wire`], which is total).
fn try_from(__s: &str) -> ::core::result::Result<Self, Self::Error> {
match __s {
"in" => ::core::result::Result::Ok(Self::In),
"out" => ::core::result::Result::Ok(Self::Out),
"in_out" => ::core::result::Result::Ok(Self::InOut),
_ => ::core::result::Result::Err(UnknownBmmParameterDirection(__s.to_owned())),
}
}
}
/// The error returned by [`BmmParameterDirection::try_from`] for a value outside the `BMM_PARAMETER_DIRECTION`
/// constant set.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnknownBmmParameterDirection(pub String);
impl ::core::fmt::Display for UnknownBmmParameterDirection {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
::core::write!(f, "unknown BMM_PARAMETER_DIRECTION value: {:?}", self.0)
}
}
impl ::std::error::Error for UnknownBmmParameterDirection {}