1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! 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
//!
//! ```text
//! 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:
//!
//! | Stage | Serialized data | Required features / bounds |
//! |-------|-----------------|----------------------------|
//! | 1 — Record UI | `ConfigType`, leaf configs | `cotis/serialization`; leaf types: [`Serialize`] |
//! | 1 — Record layout | `Vec<ElementsOutput>` | `cotis-layout/serialization` |
//! | 2 — Replay UI | `ConfigType` + [`LeafConfigList`](serialize_targets::leaf_serialization::LeafConfigList) | `ConfigType: DeserializeOwned` |
//! | 3 — Render-only | e.g. `RenderCommandOutput` from `cotis-layout` | `cotis-layout/serialization` |
//!
//! [`ElementsOutput`] must implement [`Serialize`] + [`DeserializeOwned`] for file I/O helpers
//! in [`layout_module_debugger`].
//!
//! # Quick start
//!
//! **Record pass:**
//!
//! ```rust,ignore
//! 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):**
//!
//! ```rust,ignore
//! let decl = LeafedInterfaceDeclaration::load_from(path, Leafs::new())?;
//! // compute_frame(&mut app, &decl) — decl implements UiFn
//! ```
//!
//! **Render-only (stage 3):**
//!
//! ```rust,ignore
//! 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
//!
//! - [`declaration_debugger`] — debug wrappers around [`cotis::element_configuring`] that
//! record every `open` / `configure` / `close` into a [`LeafedInterfaceDeclaration`](serialize_targets::LeafedInterfaceDeclaration).
//! - [`serialize_targets`] — instruction-stream types, JSON persistence, and leaf-config
//! type-list machinery for deserialization.
//! - [`layout_module_debugger`] — capture layout output to JSON; replay declarations through
//! a layout manager in isolation.
//! - [`render_module_debugger`] — replay precomputed render commands through a renderer when
//! layout-manager init side effects are needed.
//!
//! [`cotis`]: https://docs.rs/cotis
//! [`Serialize`]: serde::Serialize
//! [`DeserializeOwned`]: serde::de::DeserializeOwned
//! [`ElementsOutput`]: cotis::layout::LayoutManager