rite_model/params/
verification.rs1use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use crate::types::Vocabulary;
7
8#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
10#[serde(deny_unknown_fields)]
11#[non_exhaustive]
12pub struct ClockCheckParams {
13 #[serde(default)]
15 pub message: Option<String>,
16}
17
18#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
20#[serde(deny_unknown_fields)]
21#[non_exhaustive]
22pub struct ConfirmParams {
23 #[serde(default)]
25 pub message: Option<String>,
26}
27
28#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
30#[serde(into = "String", try_from = "String")]
31#[non_exhaustive]
32pub enum ReadbackFormat {
33 #[default]
35 NatoPhonetic,
36 Hex,
38 Raw,
40}
41
42crate::types::vocabulary!(ReadbackFormat {
43 NatoPhonetic => "nato_phonetic" | "nato",
44 Hex => "hex",
45 Raw => "raw",
46});
47
48impl From<ReadbackFormat> for String {
49 fn from(format: ReadbackFormat) -> Self {
50 format.as_str().to_string()
51 }
52}
53
54impl TryFrom<String> for ReadbackFormat {
55 type Error = String;
56
57 fn try_from(s: String) -> Result<Self, Self::Error> {
58 Self::from_name(&s).ok_or_else(|| {
59 format!(
60 "unknown readback format '{s}': expected {}",
61 crate::types::either(Self::ALL.iter().map(|format| format.as_str()))
62 )
63 })
64 }
65}
66
67impl JsonSchema for ReadbackFormat {
68 fn schema_name() -> std::borrow::Cow<'static, str> {
69 "ReadbackFormat".into()
70 }
71
72 fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
73 Self::names_schema()
74 }
75}
76
77#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
79#[serde(deny_unknown_fields)]
80#[non_exhaustive]
81pub struct OralReadbackParams {
82 #[serde(default)]
85 pub message: Option<String>,
86 #[serde(default)]
88 pub value: Option<String>,
89 #[serde(default)]
91 pub format: Option<ReadbackFormat>,
92 #[serde(default)]
94 pub characters: Option<u32>,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
102#[serde(deny_unknown_fields)]
103#[non_exhaustive]
104pub struct CheckValueParams {
105 pub actual: String,
107 pub expected: String,
109 #[serde(default)]
111 pub message: Option<String>,
112 #[serde(default)]
114 pub sensitive: bool,
115}
116
117#[allow(clippy::struct_excessive_bools)]
119#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
120#[serde(deny_unknown_fields)]
121#[non_exhaustive]
122pub struct MachineInfoParams {
123 #[serde(default = "default_true")]
125 pub include_machine_id: bool,
126 #[serde(default = "default_true")]
128 pub include_cpu: bool,
129 #[serde(default = "default_true")]
131 pub include_os: bool,
132 #[serde(default = "default_true")]
134 pub include_security_features: bool,
135 #[serde(default)]
137 pub message: Option<String>,
138}
139
140fn default_true() -> bool {
141 true
142}
143
144impl Default for MachineInfoParams {
145 fn default() -> Self {
146 Self {
147 include_machine_id: true,
148 include_cpu: true,
149 include_os: true,
150 include_security_features: true,
151 message: None,
152 }
153 }
154}