pub trait DebugState {
// Required method
fn debug_sections(&self) -> Vec<DebugSection>;
// Provided method
fn build_debug_table(&self, title: impl Into<String>) -> DebugTableOverlay { ... }
}Expand description
Trait for types that can provide debug state information
Implement this trait to enable the state overlay in debug mode.
§Example
use tui_dispatch_core::debug::{DebugState, DebugSection, DebugEntry};
struct AppState {
host: String,
connected: bool,
item_count: usize,
}
impl DebugState for AppState {
fn debug_sections(&self) -> Vec<DebugSection> {
vec![
DebugSection::new("Connection")
.entry("host", &self.host)
.entry("connected", self.connected.to_string()),
DebugSection::new("Data")
.entry("items", self.item_count.to_string()),
]
}
}Required Methods§
Sourcefn debug_sections(&self) -> Vec<DebugSection>
fn debug_sections(&self) -> Vec<DebugSection>
Return state as sections with key-value pairs
Provided Methods§
Sourcefn build_debug_table(&self, title: impl Into<String>) -> DebugTableOverlay
fn build_debug_table(&self, title: impl Into<String>) -> DebugTableOverlay
Build a debug table overlay from the state
Default implementation uses debug_sections().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl DebugState for ()
Implementation for unit type (no state to show)
impl DebugState for ()
Implementation for unit type (no state to show)
fn debug_sections(&self) -> Vec<DebugSection>
Source§impl<A: DebugState, B: DebugState> DebugState for (A, B)
Implementation for tuples - combine multiple state sources
impl<A: DebugState, B: DebugState> DebugState for (A, B)
Implementation for tuples - combine multiple state sources
fn debug_sections(&self) -> Vec<DebugSection>
Source§impl<A: DebugState, B: DebugState, C: DebugState> DebugState for (A, B, C)
impl<A: DebugState, B: DebugState, C: DebugState> DebugState for (A, B, C)
fn debug_sections(&self) -> Vec<DebugSection>
Source§impl<T: DebugState> DebugState for &T
Implementation for references
impl<T: DebugState> DebugState for &T
Implementation for references
fn debug_sections(&self) -> Vec<DebugSection>
Source§impl<T: DebugState> DebugState for &mut T
impl<T: DebugState> DebugState for &mut T
fn debug_sections(&self) -> Vec<DebugSection>
Implementors§
impl<T: Debug> DebugState for DebugWrapper<'_, T>
Blanket implementation for types implementing Debug
Provides a basic fallback that renders the Debug output. Types should implement DebugState directly for better formatting.