Skip to content

feat(model)!: introduce DeviceTreeNodeRef - #96

Open
m4tx wants to merge 1 commit into
mainfrom
node-trait-1
Open

m4tx wants to merge 1 commit into
mainfrom
node-trait-1

Conversation

@m4tx

@m4tx m4tx commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

This change adds as_read_only method that returns a reference struct pointing to the DeviceTreeNode and removes impl Node for &DeviceTreeNode.

There are two main reasons for making this change:

  • Unifying FdtNodeMut and DeviceTreeNode - since FdtNodeMut contains a mutable reference, it cannot be Copy, so for the Node trait implementation it exposes its own as_read_only method.
  • This allows us to properly store parent_address_space in objects returned by child(), find_node, etc. without any lifetime issues, self-referential structs, mutability problems, or similar.

The main tradeoff is convenience - the users would need to call as_read_only() for every reading operation. To avoid this, convenience wrapper methods are added and unified via a macro shared by FdtNodeMut and DeviceTreeNode.

@m4tx
m4tx requested a review from qwandor October 20, 2026 14:10
@m4tx
m4tx added this pull request to stack #98 October 20, 2026 14:11
This change adds `as_read_only` method that returns a reference struct
pointing to the `DeviceTreeNode` and removes `impl Node for
&DeviceTreeNode`.

There are two main reasons for making this change:
* Unifying `FdtNodeMut` and `DeviceTreeNode` - since `FdtNodeMut`
  contains a mutable reference, it cannot be `Copy`, so for
  the `Node` trait implementation it exposes its own `as_read_only`
  method.
* This allows us to properly store `parent_address_space` in objects
  returned by `child()`, `find_node`, etc. without any lifetime issues,
  self-referential structs, mutability problems, or similar.

The main tradeoff is convenience - the users would need to call
`as_read_only()` for every reading operation. To avoid this, convenience
wrapper methods are added and unified via a macro shared by `FdtNodeMut`
and `DeviceTreeNode`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant