prodable machines

This commit is contained in:
Nadja Reitzenstein
2023-02-14 16:58:23 +01:00
parent 198845f176
commit d196050fe0
4 changed files with 38 additions and 4 deletions

View File

@ -59,6 +59,16 @@ pub struct MachineDescription {
/// The permission required
#[serde(flatten)]
pub privs: PrivilegesBuf,
#[serde(default = "default_prodable", skip_serializing_if = "bool_is_false", deserialize_with = "deser_bool")]
pub prodable: bool,
}
fn default_prodable() -> bool {
false
}
fn bool_is_false(b: &bool) -> bool {
!b
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -116,6 +126,14 @@ pub struct ModuleConfig {
pub params: HashMap<String, String>,
}
fn deser_bool<'de, D>(d: D) -> Result<bool, D::Error>
where
D: serde::Deserializer<'de>,
{
Ok(bool::deserialize(d).unwrap_or(false))
}
pub(crate) fn deser_option<'de, D, T>(d: D) -> std::result::Result<Option<T>, D::Error>
where
D: serde::Deserializer<'de>,