Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions rust/crates/i14-config/src/charge_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct ChargeStatus {
pub limit: i64,
pub error: Option<String>,
pub online: Option<bool>,
/// True when `level` comes from an anchored HW coulomb counter (display `N%`, not `~N%`).
pub anchored: bool,
/// The whole snapshot, for fields only the guard uses.
pub raw: Map<String, Value>,
}
Expand Down Expand Up @@ -90,6 +92,11 @@ pub fn parse(text: &str, now: f64, boot_id: &str, max_age: Option<f64>) -> Optio
Some(Value::Bool(b)) => Some(*b),
Some(_) => return None,
};
let anchored = match data.get("anchored") {
None | Some(Value::Null) => false,
Some(Value::Bool(b)) => *b,
Some(_) => return None,
};
if level.is_none() != zcv_mv.is_none() {
return None;
}
Expand All @@ -102,6 +109,7 @@ pub fn parse(text: &str, now: f64, boot_id: &str, max_age: Option<f64>) -> Optio
limit,
error,
online,
anchored,
raw: data,
})
}
Expand Down
Loading