Rust Snapshot workflow
This is the complete, compile-checked package recipe. The caller owns the device and application state.
rust
use zenfg_snapshot::{
FRAME_GRAPH_SNAPSHOT_FORMAT, FRAME_GRAPH_SNAPSHOT_VERSION, decode_frame_graph_snapshot,
to_json_pretty,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let value = serde_json::json!({
"format": FRAME_GRAPH_SNAPSHOT_FORMAT,
"version": FRAME_GRAPH_SNAPSHOT_VERSION,
"producer": { "name": "snapshot-basic-example" },
"capture": { "frameIndex": 0 },
"graph": {
"groups": [],
"nodes": [],
"resources": [],
"textureViews": [],
"accesses": [],
"dependencies": [],
"roots": [],
"segments": []
},
"memory": {
"allocationReport": { "status": "available", "allocations": [] },
"poolReport": { "status": "unavailable", "reason": "not captured" }
},
"timings": {
"cpu": { "status": "unavailable", "reason": "not-requested" },
"gpu": { "status": "unavailable", "reason": "not captured" }
},
"diagnostics": [],
"extensions": {}
});
let decoded = decode_frame_graph_snapshot(value)?;
assert_eq!(decoded.snapshot.format, FRAME_GRAPH_SNAPSHOT_FORMAT);
assert_eq!(decoded.snapshot.version, FRAME_GRAPH_SNAPSHOT_VERSION);
println!("{}", to_json_pretty(&decoded.snapshot)?);
Ok(())
}