pub fn runtime_receipt_to_json<T>(receipt: &RuntimeReceipt<T>) -> Valuewhere
T: RuntimeReceiptResultJson,Examples found in repository?
examples/runtime_persistence.rs (line 24)
19fn run() -> Result<(), Box<dyn std::error::Error>> {
20 let path = temp_state_path("runtime");
21 let mut runtime = KernelRuntime::load(JsonFileStore::new(&path))?;
22
23 let receipt = runtime.write_with_receipt("apps.demo.home.count", 3_u64)?;
24 let json = runtime_receipt_to_json(&receipt);
25
26 assert_eq!(json["events"][0]["path"][0], "apps");
27 assert_eq!(json["events"][0]["path"][2], "home");
28 assert_eq!(json["events"][0]["value"], 3.0);
29
30 let restored = KernelRuntime::load(JsonFileStore::new(&path))?;
31 assert_eq!(
32 restored.read("apps.demo.home.count"),
33 Some(&Value::from(3_u64))
34 );
35 assert!(restored.events().is_empty());
36
37 println!("{json}");
38 let _ = fs::remove_file(path);
39 Ok(())
40}