assemble_core/task/work_handler/
serializer.rs1#[cfg(feature = "ron")]
4mod ron;
5#[cfg(feature = "ron")]
6pub use ron::*;
7
8#[cfg(feature = "compact")]
9mod compact;
10#[cfg(feature = "compact")]
11pub use compact::*;
12
13#[cfg(not(any(feature = "ron", feature = "compact")))]
14mod json;
15#[cfg(not(any(feature = "ron", feature = "compact")))]
16pub use json::*;
17
18#[cfg(test)]
19mod tests {
20 use super::*;
21
22 #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
23 struct TestStruct {
24 a: i32,
25 b: String,
26 }
27
28 #[test]
29 fn can_serialize_generics() {
30 let test_struct = TestStruct {
31 a: 15,
32 b: "Hello, World".to_string(),
33 };
34 let serialized = Serializable::new(test_struct.clone()).unwrap();
35 println!("serialized: {}", to_string(&serialized).unwrap());
36 let value: TestStruct = serialized.deserialize().unwrap();
37 assert_eq!(value, test_struct);
38 }
39}