Skip to main content

Crate cotis_modules_debug

Crate cotis_modules_debug 

Source
Expand description

Record, replay, and isolate Cotis modules for debugging layout, UI declaration, and render pipelines.

Cotis builds native UIs through a modular pipeline: UI code declares an element tree, a layout manager computes geometry, and a renderer draws the result. Running the full app stack for every investigation is slow. This crate captures intermediate artifacts as JSON so you can replay individual stages in isolation.

§Three-stage debug pipeline

Stage 1 — Record (live app + debug wrappers)
  UI uses DebugInitialConfiguredParentElement / DebugOpenElement / ...
    → LeafedInterfaceDeclaration → interface_*.json
  LayoutModuleCapture wraps a LayoutManager
    → store_computed_layout → elements_*.json

Stage 2 — Replay UI declaration (layout only, normal app)
  LeafedInterfaceDeclaration::load_from(...)
    → implements UiFn → rebuilds element tree without debug wrappers

Stage 3 — Render-only (skip layout entirely)
  load_computed_layout(...)
    → CotisLayoutToRenderListPipeForGenerics::transform
    → renderer.draw_frame(...)

See the gradients_example_solid, gradients_example_solid_replay, and gradients_example_solid_render_only examples for a complete walkthrough.

§Serialization requirements

This crate always depends on cotis with the serialization feature. Consumers must also enable serialization on the types they capture:

StageSerialized dataRequired features / bounds
1 — Record UIConfigType, leaf configscotis/serialization; leaf types: Serialize
1 — Record layoutVec<ElementsOutput>cotis-layout/serialization
2 — Replay UIConfigType + LeafConfigListConfigType: DeserializeOwned
3 — Render-onlye.g. RenderCommandOutput from cotis-layoutcotis-layout/serialization

ElementsOutput must implement Serialize + DeserializeOwned for file I/O helpers in layout_module_debugger.

§Quick start

Record pass:

use cotis_modules_debug::declaration_debugger::debug_element_configuring::DebugInitialConfiguredParentElement;
use cotis_modules_debug::layout_module_debugger::capture::LayoutModuleCapture;
use cotis_modules_debug::layout_module_debugger::store_computed_layout;
use cotis_modules_debug::serialize_targets::{LeafedInterfaceDeclaration, SerializedInterfaceDeclaration};
use cotis_modules_debug::serialize_targets::leaf_serialization::{LeafConfigList, LeafConfigListNil};

type Leafs = LeafConfigList<TextElementConfig<'static>, LeafConfigListNil>;
let mut decl = LeafedInterfaceDeclaration::new(SerializedInterfaceDeclaration::new(), Leafs::new());
// Wrap layout root: DebugInitialConfiguredParentElement::new(layout, &mut decl)
// ... build UI ...
decl.store_in(path)?;
store_computed_layout(app.layout_manager().output(), path)?;

Replay pass (stage 2):

let decl = LeafedInterfaceDeclaration::load_from(path, Leafs::new())?;
// compute_frame(&mut app, &decl)  — decl implements UiFn

Render-only (stage 3):

use cotis_layout::layout_struct::RenderCommandOutput;
use cotis_pipes::cotis_layout_pipes::CotisLayoutToRenderListPipeForGenerics;

let output = load_computed_layout::<RenderCommandOutput<ExampleConfig>>(path)?;
let cmds: Vec<_> = pipe.transform(output.into_iter()).collect();
renderer.draw_frame(cmds.into_iter());

§Module map

Modules§

declaration_debugger
Debug wrappers that record UI declaration operations while building a live interface.
layout_module_debugger
Capture and replay layout-module output for debugging.
render_module_debugger
Renderer replay wrapper for re-drawing saved render command streams.
serialize_targets
Serializable UI declaration instruction streams and leaf-config type lists.