use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::types::Vocabulary;
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ClockCheckParams {
#[serde(default)]
pub message: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ConfirmParams {
#[serde(default)]
pub message: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(into = "String", try_from = "String")]
#[non_exhaustive]
pub enum ReadbackFormat {
#[default]
NatoPhonetic,
Hex,
Raw,
}
crate::types::vocabulary!(ReadbackFormat {
NatoPhonetic => "nato_phonetic" | "nato",
Hex => "hex",
Raw => "raw",
});
impl From<ReadbackFormat> for String {
fn from(format: ReadbackFormat) -> Self {
format.as_str().to_string()
}
}
impl TryFrom<String> for ReadbackFormat {
type Error = String;
fn try_from(s: String) -> Result<Self, Self::Error> {
Self::from_name(&s).ok_or_else(|| {
format!(
"unknown readback format '{s}': expected {}",
crate::types::either(Self::ALL.iter().map(|format| format.as_str()))
)
})
}
}
impl JsonSchema for ReadbackFormat {
fn schema_name() -> std::borrow::Cow<'static, str> {
"ReadbackFormat".into()
}
fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
Self::names_schema()
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct OralReadbackParams {
#[serde(default)]
pub message: Option<String>,
#[serde(default)]
pub value: Option<String>,
#[serde(default)]
pub format: Option<ReadbackFormat>,
#[serde(default)]
pub characters: Option<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct CheckValueParams {
pub actual: String,
pub expected: String,
#[serde(default)]
pub message: Option<String>,
#[serde(default)]
pub sensitive: bool,
}
#[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct MachineInfoParams {
#[serde(default = "default_true")]
pub include_machine_id: bool,
#[serde(default = "default_true")]
pub include_cpu: bool,
#[serde(default = "default_true")]
pub include_os: bool,
#[serde(default = "default_true")]
pub include_security_features: bool,
#[serde(default)]
pub message: Option<String>,
}
fn default_true() -> bool {
true
}
impl Default for MachineInfoParams {
fn default() -> Self {
Self {
include_machine_id: true,
include_cpu: true,
include_os: true,
include_security_features: true,
message: None,
}
}
}