Repository navigation
Conversation
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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds
as_read_onlymethod that returns a reference struct pointing to theDeviceTreeNodeand removesimpl Node for &DeviceTreeNode.There are two main reasons for making this change:
FdtNodeMutandDeviceTreeNode- sinceFdtNodeMutcontains a mutable reference, it cannot beCopy, so for theNodetrait implementation it exposes its ownas_read_onlymethod.parent_address_spacein objects returned bychild(),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 byFdtNodeMutandDeviceTreeNode.