pub struct DebugLayer<A> { /* private fields */ }Expand description
High-level debug layer with minimal configuration.
Provides automatic freeze/unfreeze with pause/resume of tasks and subscriptions.
§Example
use crossterm::event::KeyCode;
use tui_dispatch::debug::DebugLayer;
// Minimal setup - just the toggle key
let mut debug = DebugLayer::new(KeyCode::F(12))
.with_task_manager(&tasks)
.with_subscriptions(&subs)
.active(args.debug);
// In event loop
if debug.intercepts(&event) {
continue;
}
// In render
debug.render(frame, |f, area| {
app.render(f, area);
});
// Log actions for the action log feature
debug.log_action(&action);Implementations§
Source§impl<A: Action> DebugLayer<A>
impl<A: Action> DebugLayer<A>
Sourcepub fn active(self, active: bool) -> Self
pub fn active(self, active: bool) -> Self
Set whether the debug layer is active.
When inactive (false), all methods become no-ops with zero overhead.
Sourcepub fn with_action_log_capacity(self, capacity: usize) -> Self
pub fn with_action_log_capacity(self, capacity: usize) -> Self
Set the action log capacity.
Sourcepub fn with_style(self, style: DebugStyle) -> Self
pub fn with_style(self, style: DebugStyle) -> Self
Set custom style.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if debug mode is enabled (and layer is active).
Sourcepub fn is_state_overlay_visible(&self) -> bool
pub fn is_state_overlay_visible(&self) -> bool
Check if the state overlay is currently visible.
Sourcepub fn freeze(&self) -> &DebugFreeze<A>
pub fn freeze(&self) -> &DebugFreeze<A>
Get a reference to the underlying freeze state.
Sourcepub fn freeze_mut(&mut self) -> &mut DebugFreeze<A>
pub fn freeze_mut(&mut self) -> &mut DebugFreeze<A>
Get a mutable reference to the underlying freeze state.
Sourcepub fn log_action<T: ActionParams>(&mut self, action: &T)
pub fn log_action<T: ActionParams>(&mut self, action: &T)
Log an action to the action log.
Call this when dispatching actions to record them for the debug overlay.
Sourcepub fn action_log(&self) -> &ActionLog
pub fn action_log(&self) -> &ActionLog
Get the action log.
Sourcepub fn render<F>(&mut self, frame: &mut Frame<'_>, render_fn: F)
pub fn render<F>(&mut self, frame: &mut Frame<'_>, render_fn: F)
Render with automatic debug handling.
When debug mode is disabled, simply calls render_fn with the full frame area.
When enabled, captures/paints the frozen snapshot and renders debug overlay.
Sourcepub fn split_area(&self, area: Rect) -> (Rect, Rect)
pub fn split_area(&self, area: Rect) -> (Rect, Rect)
Split area for manual layout control.
Sourcepub fn intercepts(&mut self, event: &EventKind) -> bool
pub fn intercepts(&mut self, event: &EventKind) -> bool
Sourcepub fn intercepts_with_effects(
&mut self,
event: &EventKind,
) -> Option<Vec<DebugSideEffect<A>>>
pub fn intercepts_with_effects( &mut self, event: &EventKind, ) -> Option<Vec<DebugSideEffect<A>>>
Check if debug layer intercepts an event, returning any side effects.
Returns None if the event was not consumed, Some(effects) if it was.
Sourcepub fn show_state_overlay<S: DebugState>(&mut self, state: &S)
pub fn show_state_overlay<S: DebugState>(&mut self, state: &S)
Show state overlay using a DebugState implementor.
Sourcepub fn show_action_log(&mut self)
pub fn show_action_log(&mut self)
Show action log overlay.
Sourcepub fn queue_action(&mut self, action: A)
pub fn queue_action(&mut self, action: A)
Queue an action to be processed when debug mode is disabled.
Sourcepub fn take_queued_actions(&mut self) -> Vec<A>
pub fn take_queued_actions(&mut self) -> Vec<A>
Take any queued actions (from task manager resume).
Call this after intercepts() returns effects to get queued actions
that should be dispatched.
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for DebugLayer<A>
impl<A> RefUnwindSafe for DebugLayer<A>where
A: RefUnwindSafe,
impl<A> Send for DebugLayer<A>where
A: Send,
impl<A> Sync for DebugLayer<A>where
A: Sync,
impl<A> Unpin for DebugLayer<A>where
A: Unpin,
impl<A> UnwindSafe for DebugLayer<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more