#![deny(missing_docs)]
pub mod merge;
pub mod redact;
#[cfg(feature = "client")]
pub mod api;
#[cfg(feature = "client")]
pub mod config;
#[cfg(feature = "client")]
pub mod evaluate;
#[cfg(feature = "client")]
pub mod identity;
#[cfg(feature = "client")]
pub mod worker;
pub use merge::Merger;
pub use redact::Redactor;
use time::OffsetDateTime;
pub fn now() -> String {
let fmt = time::macros::format_description!(
"[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:3]Z"
);
OffsetDateTime::now_utc()
.format(&fmt)
.expect("the timestamp format is a compile-time constant")
}
pub fn user_agent() -> String {
format!(
"recall-worker/{} ({}-{})",
recall_wire::discovery::version(),
std::env::consts::OS,
std::env::consts::ARCH
)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn timestamps_match_javascripts_toisostring() {
let t = now();
assert_eq!(t.len(), 24, "got {t}");
assert!(t.ends_with('Z') && &t[10..11] == "T" && &t[19..20] == ".");
}
#[test]
fn the_agent_names_the_worker() {
assert!(
user_agent().starts_with("recall-worker/"),
"{}",
user_agent()
);
}
}