use serde_json::Value;
use crate::boundary::codec::fields::{bool_of, i64_of, opt, str_of};
pub(super) fn client_row(v: &Value) -> Result<crate::registry::roster::ClientRow, String> {
let o = v.as_object().ok_or("client row: not an object")?;
Ok(crate::registry::roster::ClientRow {
client: str_of(o, "client")?,
present: bool_of(o, "present")?,
tools: crate::registry::tools::decode(o.get("tools").ok_or("client row: missing tools")?)?,
last_seen: opt(o, "last_seen", i64_of)?,
})
}
pub(super) fn doctor_row(v: &Value) -> Result<crate::doctor::Row, String> {
let o = v.as_object().ok_or("doctor row: not an object")?;
Ok(crate::doctor::Row {
check: str_of(o, "check")?,
ok: bool_of(o, "ok")?,
fact: str_of(o, "fact")?,
remedy: opt(o, "remedy", str_of)?,
})
}