1use rusqlite::Row;
7use uls_core::codes::{LicenseStatus, OperatorClass, RadioService};
8
9pub fn read_license_status(row: &Row, idx: usize) -> rusqlite::Result<char> {
13 let code: Option<i64> = row.get(idx)?;
14 Ok(code
15 .and_then(|c| LicenseStatus::from_u8(c as u8))
16 .map(|s| s.as_str().chars().next().unwrap_or('?'))
17 .unwrap_or('?'))
18}
19
20pub fn read_radio_service(row: &Row, idx: usize) -> rusqlite::Result<String> {
24 let code: Option<i64> = row.get(idx)?;
25 Ok(code
26 .and_then(|c| RadioService::from_u8(c as u8))
27 .map(|r| r.as_str().to_string())
28 .unwrap_or_default())
29}
30
31pub fn read_operator_class(row: &Row, idx: usize) -> rusqlite::Result<Option<char>> {
35 let code: Option<i64> = row.get(idx)?;
36 Ok(code
37 .and_then(|c| OperatorClass::from_u8(c as u8))
38 .map(|o| o.as_str().chars().next().unwrap_or('?')))
39}
40
41#[cfg(test)]
42mod tests {
43 }