#[ui_debug] attribute macro turns a struct or enum into a UI-visible data node. Annotated types appear in the browser graph with a db badge and can emit snapshots of their state at any point during execution. Snapshots are displayed in the node details panel alongside the sequence of traced function calls.
Usage
Add#[ui_debug] above any struct or enum definition:
#[ui_debug] automatically derives Debug on your type if it is not already present. You do not need to add #[derive(Debug)] separately.Arguments
Optional display label shown in the browser UI. Defaults to the type name as written in source.
The emit_snapshot method
Annotating a type with #[ui_debug] adds an emit_snapshot method to every instance of that type. Call it at any point to capture the current state of the value and attach it to the active session:
label argument is a short string that identifies what was happening at the time of the snapshot. It appears as the snapshot title in the UI’s output panel for the enclosing traced function.
Example
The following example shows a struct with snapshot emissions inside a traced function:emit_snapshot call produces a value_snapshot event in the session. In the browser UI, these appear in the output section of the enclosing traced function node, in the order they were emitted.
Using #[ui_debug] on enums
Enums are supported exactly like structs. All variants are captured through Debug formatting: