1use std::path::{Path, PathBuf};
2
3#[macro_use]
4pub mod macros;
5#[macro_use]
6extern crate bitflags;
7
8pub mod error;
9pub mod log;
10pub(crate) mod records;
11pub(crate) mod util;
12
13#[cfg(test)]
14mod test;
15
16pub use error::DatalogError;
17
18type WpiTimestamp = u64;
20type EntryId = u32;
22type EntryName = String;
24type EntryType = String;
26type EntryMetadata = String;
28type LeBytes = Vec<u8>;
30type LeByte = u8;
32type EntryTypeMap = std::collections::HashMap<EntryId, EntryType>;
34type EntryIdToNameMap = bimap::BiMap<EntryId, EntryName>;
36
37pub fn sec_from_micros(micros: WpiTimestamp) -> f64 {
38 micros as f64 / 1_000_000.0
39}
40
41pub fn now() -> WpiTimestamp {
42 let now = std::time::SystemTime::now();
43 let duration = now.duration_since(std::time::UNIX_EPOCH).unwrap();
44 duration.as_micros() as WpiTimestamp
45}
46
47pub fn absolute_path(rel_path: &Path) -> PathBuf {
48 let cwd = std::env::current_dir().unwrap();
50 cwd.join(rel_path)
52}