inspect-format 0.1.0

Formatting and rendering for inspect-rs
Documentation
//! Semantic style roles for inspected elements.

/// Semantic role of an inspected element within output formatting.
///
/// Instead of hard-coding raw colors or escape codes in renderers, renderers
/// request styles by semantic role. Themes map these roles to concrete terminal
/// styles.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum StyleRole {
    /// Type names (e.g. `Server`, `User`, `Vec<i32>`).
    Type,

    /// Field or property names in structs/records (e.g. `host`, `port`).
    Field,

    /// Enum variant names (e.g. `Running`, `Some`, `Ok`).
    Variant,

    /// Map keys or dictionary entries (e.g. `"host"`, `"port"`).
    Key,

    /// String literal values (e.g. `"127.0.0.1"`).
    String,

    /// Numeric values (e.g. `42`, `3.14`, `-12`, `0xff`).
    Number,

    /// Boolean values (`true`, `false`).
    Boolean,

    /// Unit or null-like values (`()`, `None`).
    Null,

    /// Structural punctuation (e.g. `:`, `""`, `[]`, `()`, `::`).
    Punctuation,

    /// Collection element indices (e.g. `[0]`, `[1]`).
    Index,

    /// Metadata annotations (e.g. `[16 bytes]`, length indicators).
    Metadata,

    /// Sensitive or redacted values (e.g. `[REDACTED]`).
    Sensitive,

    /// Truncation notices (e.g. `… 997 more`, `<truncated>`).
    Truncated,

    /// Error messages or error variants (e.g. `Err`, `<cycle>`).
    Error,

    /// Subdued or muted secondary text.
    Muted,
}

impl StyleRole {
    /// Total number of semantic roles.
    pub const COUNT: usize = 15;

    /// Return an array of all semantic roles.
    pub const ALL: [Self; Self::COUNT] = [
        Self::Type,
        Self::Field,
        Self::Variant,
        Self::Key,
        Self::String,
        Self::Number,
        Self::Boolean,
        Self::Null,
        Self::Punctuation,
        Self::Index,
        Self::Metadata,
        Self::Sensitive,
        Self::Truncated,
        Self::Error,
        Self::Muted,
    ];

    /// Returns the integer index corresponding to this role (0 to 14).
    #[inline]
    pub const fn index(self) -> usize {
        self as usize
    }
}