pub struct RuntimeInspector { /* private fields */ }Expand description
Registry of named runtime objects that can be inspected and modified.
Objects are stored as type-erased Any; the inspector functions are
stored as closures that know the concrete type at registration time.
Implementations§
Source§impl RuntimeInspector
impl RuntimeInspector
pub fn new() -> Self
Sourcepub fn register<T>(&mut self, name: impl Into<String>, obj: T)where
T: Inspectable + Any + 'static,
pub fn register<T>(&mut self, name: impl Into<String>, obj: T)where
T: Inspectable + Any + 'static,
Register an Inspectable object under name.
The object is cloned into the registry. Mutations via apply modify
the stored copy; use get_object::<T>() to retrieve the current value.
Sourcepub fn inspect(&self, name: &str) -> Option<Vec<InspectorField>>
pub fn inspect(&self, name: &str) -> Option<Vec<InspectorField>>
Return the inspector fields for the named object, or None if not found.
Sourcepub fn apply(&mut self, name: &str, changes: Vec<(String, InspectorValue)>)
pub fn apply(&mut self, name: &str, changes: Vec<(String, InspectorValue)>)
Apply changes to the named object.
Sourcepub fn watch(&self, name: &str) -> Option<InspectorWatcher>
pub fn watch(&self, name: &str) -> Option<InspectorWatcher>
Create an InspectorWatcher for the named object.
The watcher is seeded with the current field values.
Sourcepub fn get_object<T: Any>(&self, name: &str) -> Option<&T>
pub fn get_object<T: Any>(&self, name: &str) -> Option<&T>
Get a reference to the stored object as type T.
Sourcepub fn get_object_mut<T: Any>(&mut self, name: &str) -> Option<&mut T>
pub fn get_object_mut<T: Any>(&mut self, name: &str) -> Option<&mut T>
Get a mutable reference to the stored object as type T.
Sourcepub fn unregister(&mut self, name: &str)
pub fn unregister(&mut self, name: &str)
Remove an object from the registry.
pub fn is_empty(&self) -> bool
Sourcepub fn format_table(&self) -> String
pub fn format_table(&self) -> String
Render a simple text table of all registered objects and their fields.