Skip to main content

Crate inspect_rs

Crate inspect_rs 

Source
Expand description

§inspect-rs

Universal introspection for Rust.

inspect-rs provides a lightweight protocol for structured introspection of Rust values without coupling to debuggers, serializers, or specific UI frameworks.

§Quick Start

use inspect_rs::Inspect;

#[derive(Inspect)]
struct User {
    id: u64,
    name: String,
    active: bool,
}

let user = User {
    id: 42,
    name: "Alice".to_string(),
    active: true,
};

let mut cx = inspect_rs::InspectCx::new();
let inspected = user.inspect(&mut cx);

println!("{}", inspect_rs::format_tree(&inspected));

§Design Principles

  • Lazy: Values are not eagerly traversed
  • Zero-copy: Borrows from original values where possible
  • Safe: Handles cycles, respects limits, protects secrets
  • Minimal: Zero runtime dependencies in core
  • Semantic Styling: Restrained, accessible, terminal-aware colored output

Structs§

Ansi256Color
256 (8-bit) color support
Capability
Capabilities that an inspectable value supports.
DepthGuard
RAII guard for depth tracking.
Effects
A set of text effects
FieldInfo
Metadata about a struct field or tuple element.
InspectCx
Context for an inspection session.
InspectLimits
Limits to prevent pathological inspection behavior.
InspectPath
A path through an inspected value tree.
Reset
Reset terminal formatting
RgbColor
24-bit ANSI RGB color codes
Style
A terminal style defining text effects and foreground/background colors.
Theme
A collection of styles for each semantic role.
TreeConfig
Configuration for tree formatting.
TreeFormatter
Formats inspected values as tree structures.
TypeInfo
Metadata about a type being inspected.
ValueRef
A borrowed reference to an inspected value.
VariantInfo
Metadata about an enum variant.

Enums§

AnsiColor
Available 4-bit ANSI color palette codes
Children
Children of an inspected value.
Color
Any ANSI color code scheme
ColorChoice
User preference for emitting ANSI color escape codes.
ColorLevel
Color capability tier supported by the terminal.
InspectError
Errors that can occur during inspection.
Kind
The kind of value being inspected.
PathSegment
A segment in an inspection path.
Sensitivity
Classification of data sensitivity for security-conscious rendering.
StyleRole
Semantic role of an inspected element within output formatting.

Traits§

Inspect
Provides structured introspection of a Rust value.

Functions§

format_tree
Format an inspected value as a tree with automatic terminal color detection.
format_tree_colored
Format an inspected value as a tree with ANSI color codes explicitly enabled.
format_tree_compact
Format an inspected value as a compact tree.
format_tree_plain
Format an inspected value as a tree with ANSI color codes explicitly disabled.
format_tree_with
Format an inspected value as a tree using a custom TreeConfig.

Type Aliases§

InspectResult
Result type for inspection operations.

Derive Macros§

Inspect