use crate::error::{Error, Result};
#[derive(Debug, Default, Clone, Copy)]
pub(crate) struct SessionCapabilities {
pub syst_err: Option<bool>,
pub opc: Option<bool>,
}
pub(crate) fn normalize_command(command: &str, terminator: &str) -> String {
let mut payload = command.to_string();
if !payload.ends_with(terminator) {
payload.push_str(terminator);
}
payload
}
pub(crate) fn max_write_attempts(idempotent: bool, retries: u32) -> u32 {
if idempotent {
retries + 1
} else {
1
}
}
pub fn parse_f64(response: &str) -> Result<f64> {
response
.trim()
.parse()
.map_err(|_| Error::Parse(format!("expected number, got '{response}'")))
}