fuchsia_inspect_derive

Trait Inspect

Source
pub trait Inspect {
    // Required method
    fn iattach(
        self,
        parent: &Node,
        name: impl AsRef<str>,
    ) -> Result<(), AttachError>;
}
Expand description

A trait for types that can be inspected using fuchsia_inspect and that maintain their inspect state during their lifetime. Notably, this trait is implemented for most fuchsia_inspect properties and the IOwned smart pointers. Generic implementations are also provided for interior mutability wrappers whose inner type also implement Inspect, such as RefCell and various Mutex types. This method should generally be implemented for a mutable reference (or a regular reference if the type has interior mutability).

Required Methods§

Source

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Attaches self to the inspect tree, under parent[name]. Note that:

  • If this method is called on a type with interior mutability, it will attempt to get exclusive access to the inner data, but will not wait for a mutex to unlock. If it fails, an AttachError is returned.
  • If this method is called on a fuchsia_inspect Property, it is reinitialized to its default value.

Therefore it is recommended to attach to inspect immediately after initialization, although not within constructors. Whether or not to use inspect should usually be a choice of the caller.

NOTE: Implementors should avoid returning AttachError whenever possible. It is reserved for irrecoverable invariant violations (see above). Invalid data structure invariants are not attachment errors and should instead be ignored and optionally logged.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Inspect for &mut BoolProperty

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl Inspect for &mut BytesProperty

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl Inspect for &mut DoubleProperty

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl Inspect for &mut IntProperty

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl Inspect for &mut StringProperty

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl Inspect for &mut UintProperty

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl<T> Inspect for &RefCell<T>
where for<'a> &'a mut T: Inspect,

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl<T> Inspect for &Mutex<T>
where for<'a> &'a mut T: Inspect,

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl<T> Inspect for &RwLock<T>
where for<'a> &'a mut T: Inspect,

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl<T> Inspect for &Mutex<T>
where for<'a> &'a mut T: Inspect,

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl<T> Inspect for &Mutex<T>
where for<'a> &'a mut T: Inspect,

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl<T> Inspect for &Mutex<TracingWrapper<RawSyncMutex>, T>
where for<'a> &'a mut T: Inspect,

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Source§

impl<T> Inspect for &RwLock<T>
where for<'a> &'a mut T: Inspect,

Source§

fn iattach( self, parent: &Node, name: impl AsRef<str>, ) -> Result<(), AttachError>

Implementors§

Source§

impl<R: Render> Inspect for &mut IOwned<R>