> Development branch documentation · commit 327c05c78d2f528e4f4a679fcc7a77d9aa161f48
> Package versions: @zenfg/webgpu 0.1.0, @zenfg/snapshot 0.1.0, @zenfg/inspector 0.1.0, zenfg 0.1.0, zenfg-snapshot 0.1.0
> Source: https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/crates/zenfg-snapshot/examples/basic.rs

# 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(())
}

```
