pub trait Inspect {
// Required method
fn inspect(&self, cx: &mut InspectCx<'_>) -> ValueRef<'_>;
}Expand description
Provides structured introspection of a Rust value.
This trait allows types to expose their structure and content in a way that tools, debuggers, and renderers can consume without requiring specific serialization formats or coupling to UI frameworks.
§Deriving
The recommended way to implement Inspect is via the derive macro:
ⓘ
use inspect_rs::Inspect;
#[derive(Inspect)]
struct User {
id: u64,
name: String,
}§Manual implementation
For types that need custom introspection logic:
use inspect_core::{Inspect, InspectCx, ValueRef, Kind, TypeInfo};
struct Custom(u32);
impl Inspect for Custom {
fn inspect(&self, cx: &mut InspectCx<'_>) -> ValueRef<'_> {
ValueRef::with_type(
Kind::U32(self.0),
TypeInfo::new("Custom"),
)
}
}Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".