Derive Macro fuchsia_inspect_derive::Inspect

#[derive(Inspect)]
{
    // Attributes available to this derive:
    #[inspect]
}
Expand description

The Unit derive macro can be applied to named structs in order to generate an implementation of the Unit trait. The name of the field corresponds to the inspect node or property name, and the type of the field must also implement Unit. Implementations of Unit are supplied for most primitives and String.

Example:

#[derive(Unit)] struct Point { x: f32, y: f32, } The Inspect derive macro. Requires that the type is a named struct.

If an inspect_node field is present, an inspect node will be created and used for all properties of this node. It must be of type fuchsia_inspect::Node. If inspect_node is NOT present, all Inspect fields of this type will be merged into the parent node (similar to serde’s “flatten” attribute). As a result, the name provided by the parent will be ignored (unless inspect(forward) is used, see below). This is suitable when an intermediate layer should be omitted. Care should be taken to (a) avoid name collisions between nested inspect fields of this type and the parent node’s own children and (b) ensure that the parent node outlives instances of this type, to avoid premature detachment from the inspect tree.

Supported field-level attributes:

  • inspect(skip): Ignore this field in inspect entirely.
  • inspect(rename = "foo"): Use a different name for the inspect node or property of this field. By default, the field identifier is used.
  • inspect(forward): Forward attachments directly to a child field. Only a single field can be forwarded, and inspect_node must be absent. As a result the name of the field will be unused. Useful for wrapper types. Note that other non-forward Inspect fields are allowed and their semantics are unaffected.

Type- and lifetime parameters are supported if they are ignored.