Module inspectable

Source
Expand description

Provides utilities on top of regular inspect properties to enable convenient features such as:

  • Directly mutating a value and dumping it to inspect

    use fuchsia_inspect::component;
    use fuchsia_inspect::contrib::inspectable::InspectableU64;
    
    let inspectable = InspectableU64::new(0, component::inspector::root(), "foo");
    *inspectable.get_mut() += 1;
    // The value of the u64 is 1 now and it was updated automatically in the inspect vmo.
  • Dump lengths automatically

    use fuchsia_inspect::component;
    use fuchsia_inspect::contrib::inspectable::InspectableLen;
    
    let inspectable = InspectableLen::new(vec![0], component::inspector::root(), "foo");
    // The value of the vector is [0] and the value in the inspect vmo under the foo property
    // is 1.
    *inspectable.get_mut().push(3);
    // The value of the vector is [0, 3] and the value in the inspect vmo under the foo property
    // is 2.
  • Dump debug representations automatically, etc.

    use fuchsia_inspect::component;
    use fuchsia_inspect::contrib::inspectable::InspectableDebugString;
    
    let inspectable = InspectableDebugString::new(vec![0], component::inspector::root(), "foo");
    // The value of the vector is vec![0] and the value in the inspect vmo under the foo property
    // is the debug string of the vector "[0]".
    *inspectable.get_mut().push(3);
    // The value of the vector is vec![0, 3] and the value in the inspect vmo under the foo
    // property is the debug string of the vector "[0, 3]".

Structs§

Inspectable
Generic wrapper for exporting variables via Inspect. Mutations to the wrapped value occur through an InspectableGuard, which notifies the watcher when Dropped, transparently keeping the Inspect state up-to-date.
InspectableBoolWatcher
InspectableDebugStringWatcher
Exports via an Inspect StringProperty the Debug representation of the wrapped value.
InspectableGuard
Calls self.watcher.watch(self.value) when dropped.
InspectableLenWatcher
Exports via an Inspect UintProperty the len of the wrapped container.
InspectableU64Watcher
Exports via an Inspect UintProperty a u64. Useful because the wrapped u64 value can be read.

Traits§

Len
Trait implemented by types that can provide a length. Values used for InspectableLen must implement this.
Watch
Used for exporting an [Inspectable]Inspectable’s wrapped value .

Type Aliases§

InspectableBool
InspectableDebugString
Exports via an Inspect StringProperty the Debug representation of the wrapped value V.
InspectableLen
Exports via an Inspect UintProperty the len of the wrapped value V.
InspectableU64
Exports via an Inspect UintProperty a u64. Useful because the wrapped u64 value can be read.