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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RuntimeInspector
impl !RefUnwindSafe for RuntimeInspector
impl !Send for RuntimeInspector
impl !Sync for RuntimeInspector
impl Unpin for RuntimeInspector
impl UnsafeUnpin for RuntimeInspector
impl !UnwindSafe for RuntimeInspector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.