1use log::debug;
6use objects::ObexObjectError as Error;
7
8pub mod event_report;
9pub mod messages_listing;
10
11pub(crate) const ISO_8601_TIME_FORMAT: &str = "%Y%m%dT%H%M%S";
15
16pub(crate) fn truncate_string(value: &String, max_len: usize) -> String {
19 let mut v = value.clone();
20 if v.len() <= max_len {
21 return v;
22 }
23
24 let l = v.floor_char_boundary(max_len);
25 v.truncate(l);
26
27 debug!("truncated string value from length {} to {}", value.len(), v.len());
28 v
29}
30
31pub(crate) fn str_to_bool(val: &str) -> Result<bool, Error> {
33 match val {
34 "yes" => Ok(true),
35 "no" => Ok(false),
36 val => Err(Error::invalid_data(val)),
37 }
38}
39
40pub(crate) fn bool_to_string(val: bool) -> String {
41 if val { "yes".to_string() } else { "no".to_string() }
42}