in src/serialization.rs [317:344]
fn try_from(val: AuditEntryAll) -> Result<AuditEntry, Self::Error> {
let kind = match (val.version, val.delta, val.violation) {
(Some(version), None, None) => Ok(AuditKind::Full { version }),
(None, Some(delta), None) => {
if let Some(from) = delta.from {
Ok(AuditKind::Delta { from, to: delta.to })
} else {
Err("'delta' must be a delta of the form 'VERSION -> VERSION'".to_string())
}
}
(None, None, Some(violation)) => Ok(AuditKind::Violation { violation }),
_ => Err(
"audit entires must have exactly one of 'version', 'delta', and 'violation'"
.to_string(),
),
};
Ok(AuditEntry {
who: val.who,
notes: val.notes,
criteria: val.criteria,
kind: kind?,
importable: val.importable.unwrap_or(true),
aggregated_from: val.aggregated_from,
// By default, always read entries as non-fresh. The import code
// will set this flag to true for imported entries.
is_fresh_import: false,
})
}