DebugState

Trait DebugState 

Source
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§

Source

fn debug_sections(&self) -> Vec<DebugSection>

Return state as sections with key-value pairs

Provided Methods§

Source

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)

Source§

impl<A: DebugState, B: DebugState> DebugState for (A, B)

Implementation for tuples - combine multiple state sources

Source§

impl<A: DebugState, B: DebugState, C: DebugState> DebugState for (A, B, C)

Source§

impl<T: DebugState> DebugState for &T

Implementation for references

Source§

impl<T: DebugState> DebugState for &mut T

Implementors§

Source§

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.