DebugState

Derive Macro DebugState 

Source
#[derive(DebugState)]
{
    // Attributes available to this derive:
    #[debug]
    #[debug_state]
}
Expand description

Derive macro for the DebugState trait

Automatically generates debug_sections() implementation from struct fields.

§Attributes

  • #[debug(section = "Name")] - Group field under a section
  • #[debug(skip)] - Exclude field from debug output
  • #[debug(label = "Custom Label")] - Use custom label instead of field name
  • #[debug(debug_fmt)] - Use {:?} format instead of Display
  • #[debug(format = "{:#?}")] - Use custom format string

§Example

use tui_dispatch::DebugState;

#[derive(DebugState)]
struct AppState {
    #[debug(section = "Connection")]
    host: String,
    #[debug(section = "Connection")]
    port: u16,

    #[debug(section = "UI")]
    scroll_offset: usize,

    #[debug(skip)]
    internal_cache: HashMap<String, Data>,

    #[debug(section = "Stats", debug_fmt)]
    status: ConnectionStatus,
}

Fields without a section attribute are grouped under a section named after the struct (e.g., “AppState”).