1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use chrono::{DateTime, SecondsFormat, Utc};
pub trait DateTimeUtils {
fn to_saml_datetime_string(&self) -> String;
}
impl DateTimeUtils for DateTime<Utc> {
fn to_saml_datetime_string(&self) -> String {
self.to_rfc3339_opts(SecondsFormat::Secs, true)
}
}
pub fn to_hex_string(bytes: Vec<u8>, join: Option<&str>) -> String {
let strs: Vec<String> = bytes
.iter()
.map(|b| format!("{:02X}", b).to_lowercase())
.collect();
match join {
Some(joinval) => strs.join(joinval),
None => strs.join(""),
}
}