1#![cfg_attr(test, feature(test))]
3#![deny(clippy::all, clippy::pedantic, clippy::nursery)]
4#![deny(
5 warnings,
6 missing_copy_implementations,
7 single_use_lifetimes,
8 variant_size_differences,
9 arithmetic_overflow,
10 missing_debug_implementations,
11 trivial_casts,
12 trivial_numeric_casts,
13 unused_import_braces,
14 unused_results,
15 unused_lifetimes,
16 unused_unsafe,
17 useless_ptr_null_checks,
18 cenum_impl_drop_cast,
19 while_true,
20 unused_features,
21 absolute_paths_not_starting_with_crate,
22 unused_allocation,
23 unreachable_code,
24 unused_comparisons,
25 unused_parens,
26 asm_sub_register,
27 break_with_label_and_loop,
28 bindings_with_variant_name,
29 anonymous_parameters,
30 clippy::unwrap_used,
31 clippy::panicking_unwrap,
32 missing_abi,
33 missing_fragment_specifier,
34 clippy::missing_safety_doc,
35 clippy::missing_asserts_for_indexing,
36 clippy::missing_assert_message,
37 clippy::possible_missing_comma,
38 deprecated
39)]
40#![allow(clippy::module_name_repetitions, clippy::option_if_let_else)]
41#![cfg_attr(
42 not(test),
43 forbid(
44 clippy::panic,
45 clippy::todo,
46 clippy::unimplemented,
47 clippy::expect_used
48 )
49)]
50#![cfg_attr(not(test), warn(missing_docs))]
51
52#[macro_use]
53extern crate bitflags;
54
55pub(crate) mod proto;
56
57pub mod error;
61
62pub mod reader;
66
67pub mod writer;
71
72#[cfg(test)]
73mod test;
74
75pub use error::DataLogError;
76pub use reader::DataLogReader;
77pub use writer::DataLogWriter;
78
79use frclib_core::value::FrcTimestamp;
80
81type EntryId = u32;
83type EntryName = String;
85type EntryType = String;
87type EntryMetadata = String;
89
90
91pub(crate) fn now() -> FrcTimestamp {
93 frclib_core::time::uptime().as_micros()
94 .try_into()
95 .unwrap_or(FrcTimestamp::MAX)
96}
97
98#[derive(Debug, Clone)]
100pub struct TimestampedValue<T> {
101 pub timestamp: FrcTimestamp,
103 pub value: T,
105}
106
107impl <T> TimestampedValue<T> {
108 pub const fn new(timestamp: FrcTimestamp, value: T) -> Self {
110 Self {
111 timestamp,
112 value
113 }
114 }
115
116 pub fn new_now(value: T) -> Self {
118 Self {
119 timestamp: now(),
120 value
121 }
122 }
123}