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§
- Ansi256
Color - 256 (8-bit) color support
- Capability
- Capabilities that an inspectable value supports.
- Depth
Guard - RAII guard for depth tracking.
- Effects
- A set of text effects
- Field
Info - Metadata about a struct field or tuple element.
- Inspect
Cx - Context for an inspection session.
- Inspect
Limits - Limits to prevent pathological inspection behavior.
- Inspect
Path - 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.
- Tree
Config - Configuration for tree formatting.
- Tree
Formatter - Formats inspected values as tree structures.
- Type
Info - Metadata about a type being inspected.
- Value
Ref - A borrowed reference to an inspected value.
- Variant
Info - Metadata about an enum variant.
Enums§
- Ansi
Color - Available 4-bit ANSI color palette codes
- Children
- Children of an inspected value.
- Color
- Any ANSI color code scheme
- Color
Choice - User preference for emitting ANSI color escape codes.
- Color
Level - Color capability tier supported by the terminal.
- Inspect
Error - Errors that can occur during inspection.
- Kind
- The kind of value being inspected.
- Path
Segment - A segment in an inspection path.
- Sensitivity
- Classification of data sensitivity for security-conscious rendering.
- Style
Role - 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§
- Inspect
Result - Result type for inspection operations.