1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! The core [`Inspect`] trait.
use crate::;
/// 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:
///
/// ```ignore
/// 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"),
/// )
/// }
/// }
/// ```