kenwood_thd75/protocol/
sd.rs1use crate::error::ProtocolError;
7
8use super::Response;
9
10fn parse_bool(payload: &str, cmd: &str) -> Result<bool, ProtocolError> {
12 match payload {
13 "0" => Ok(false),
14 "1" => Ok(true),
15 _ => Err(ProtocolError::FieldParse {
16 command: cmd.to_owned(),
17 field: "value".to_owned(),
18 detail: format!("expected 0 or 1, got {payload:?}"),
19 }),
20 }
21}
22
23pub(crate) fn parse_sd(mnemonic: &str, payload: &str) -> Option<Result<Response, ProtocolError>> {
27 if mnemonic != "SD" {
28 return None;
29 }
30 Some(parse_bool(payload, "SD").map(|present| Response::SdCard { present }))
31}