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 tui_dispatch::debug::DebugLayer;
// Minimal setup with sensible defaults (F12 toggle key)
let mut debug = DebugLayer::simple()
.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 simple_with_toggle_key(toggle_key: KeyCode) -> Self
pub fn simple_with_toggle_key(toggle_key: KeyCode) -> Self
Create a debug layer with a custom toggle key.
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.
Set the initial banner position.
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 toggle_enabled(&mut self) -> Option<DebugSideEffect<A>>
pub fn toggle_enabled(&mut self) -> Option<DebugSideEffect<A>>
Toggle debug mode on/off and return any side effects.
Returns None when the layer is inactive or no side effects are needed.
Sourcepub fn set_enabled(&mut self, enabled: bool) -> Option<DebugSideEffect<A>>
pub fn set_enabled(&mut self, enabled: bool) -> Option<DebugSideEffect<A>>
Set debug mode on/off and return any side effects.
Returns None when the layer is inactive or already in the requested state.
Update the banner position (top/bottom) and request a new capture.
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 render_with_state<F>(&mut self, frame: &mut Frame<'_>, render_fn: F)
pub fn render_with_state<F>(&mut self, frame: &mut Frame<'_>, render_fn: F)
Render with optional state capture for the state overlay.
render_fn receives the frame, app area, and a wants_state hint that
is true when debug mode is active and state data may be requested.
Return Some(DebugTableOverlay) to update the cached state overlay.
Sourcepub fn render_state<S: DebugState, F>(
&mut self,
frame: &mut Frame<'_>,
state: &S,
render_fn: F,
)
pub fn render_state<S: DebugState, F>( &mut self, frame: &mut Frame<'_>, state: &S, render_fn: F, )
Render with a DebugState reference and automatic state table generation.
This is a convenience wrapper around render_with_state.
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 handle_event(&mut self, event: &EventKind) -> DebugOutcome<A>
pub fn handle_event(&mut self, event: &EventKind) -> DebugOutcome<A>
Handle a debug event with a single call and return a summary outcome.
Sourcepub fn handle_event_with_state<S: DebugState>(
&mut self,
event: &EventKind,
state: &S,
) -> DebugOutcome<A>
pub fn handle_event_with_state<S: DebugState>( &mut self, event: &EventKind, state: &S, ) -> DebugOutcome<A>
Handle a debug event with access to state (for the state overlay).
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 intercepts_with_effects_and_state<S: DebugState>(
&mut self,
event: &EventKind,
state: &S,
) -> Option<Vec<DebugSideEffect<A>>>
pub fn intercepts_with_effects_and_state<S: DebugState>( &mut self, event: &EventKind, state: &S, ) -> Option<Vec<DebugSideEffect<A>>>
Check if debug layer intercepts an event with access to app state.
Use this to populate the state overlay when S is pressed.
Sourcepub fn intercepts_with_state<S: DebugState>(
&mut self,
event: &EventKind,
state: &S,
) -> bool
pub fn intercepts_with_state<S: DebugState>( &mut self, event: &EventKind, state: &S, ) -> bool
Check if debug layer intercepts an event with access to app state.
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