ratatui_toolkit/widgets/markdown_widget/state/cache_state/
mod.rs

1//! Cache state for markdown widget.
2//!
3//! Manages parsed and rendered markdown caches for efficient rendering.
4
5pub mod constructors;
6pub mod methods;
7pub mod parsed_cache;
8pub mod render_cache;
9pub mod traits;
10
11pub use constructors::*;
12pub use methods::*;
13pub use parsed_cache::ParsedCache;
14pub use render_cache::RenderCache;
15pub use traits::*;
16
17/// Cache state for markdown rendering.
18///
19/// Maintains two levels of caching:
20/// - Parsed cache: Content-dependent, width-independent
21/// - Render cache: Content and width-dependent
22#[derive(Debug, Clone)]
23pub struct CacheState {
24    /// Cache for parsed markdown elements (doesn't depend on width).
25    pub(crate) parsed: Option<ParsedCache>,
26    /// Cache for rendered lines (depends on width).
27    pub(crate) render: Option<RenderCache>,
28}
29
30impl CacheState {
31    /// Clear the render cache (e.g., when exiting filter mode).
32    pub fn clear_render_cache(&mut self) {
33        self.render = None;
34    }
35}