1pub mod serialization;
5
6pub mod pki;
10
11pub mod macros;
15
16pub mod message;
20
21pub mod transport;
25
26pub mod tokio;
30
31pub mod module;
35
36pub mod services;
40
41pub mod cli;
45
46
47pub mod actor;
51
52use std::time::{SystemTime, UNIX_EPOCH};
53
54pub fn get_timestamp_with_milliseconds() -> u128 {
58 let start = SystemTime::now();
59 let since_the_epoch = start.duration_since(UNIX_EPOCH)
60 .expect("Time went backwards");
61 since_the_epoch.as_millis()
62}
63
64#[cfg(test)]
66mod tests {
67 use super::*;
68 use libmilkyway_derive::Serializable;
69 use libmilkyway_derive::Deserializable;
70 use crate::serialization::serializable::Serializable;
71 use crate::serialization::deserializable::Deserializable;
72 use crate::serialization::serializable::Serialized;
73 use serialization::error::SerializationError;
74
75 #[derive(Serializable, Deserializable, Debug, PartialEq)]
76 struct MyStruct {
77 a: u32,
78 b: Vec<u8>,
79 }
80
81 #[test]
83 fn test_serialize_deserialize_my_struct() {
84 let my_struct = MyStruct {
85 a: 42,
86 b: vec![0, 1, 42],
87 };
88
89 let serialized = my_struct.serialize();
90 let (deserialized, _) = MyStruct::from_serialized(&serialized).unwrap();
91
92 assert_eq!(my_struct, deserialized);
93 }
94}
95