DeserializeNode

Derive Macro DeserializeNode 

Source
#[derive(DeserializeNode)]
{
    // Attributes available to this derive:
    #[dt]
}
Expand description

Derive macro generating an impl of the trait DeserializeNode.

Requires an implementation of Default.

Attribute syntax:

  • #[dt(start_cursor)]
  • #[dt(name)]
  • #[dt(unit_address)]
  • #[dt(property)]
  • #[dt(property = \"<property name>\")]
  • #[dt(child)]
  • #[dt(child = \"<node name>\")]
  • #[dt(children)]
  • #[dt(children = \"<node name>\")]
  • #[dt(children(rest))]

The default item name is the field name with undescores replaced by hyphens (and a # prepended in case the name ends with _cells), except device_type, which uses an underscore. The unit address is ignored.

  • #[dt(start_cursor)] stores a cursor to the containing node in that field (type Option<Cursor>).

  • #[dt(name)] stores the containing node’s entire name in that field (type T where T: From<&'dtb str>).

  • #[dt(unit_address)] stores the containing node’s unit address in that field (type Option<T> where T: From<&'dtb str>).

  • #[dt(property)] (default) uses DeserializeProperty

  • #[dt(child)] uses DeserializeNode

  • #[dt(children)] uses PushDeserializedNode to collect items of type Self::Node; it is similar to Extend<Self::Node>

DeserializeNode::deserialize is always used with an appropriate NodeContext.

The lifetime 'dtb (if it exists) is special because it will be used for the DeserializeNode<'dtb> implementation.