Skip to content

Conversation

@qwandor
Copy link
Collaborator

@qwandor qwandor commented Dec 16, 2025

Node is implemented by both FdtNode and &DeviceTreeNode, while Property is implemented by FdtProperty and &DeviceTreeProperty. These traits have required methods to look up properties, children, and so on, and then provide methods to get standard nodes and properties.

TODO:

  • Clean up documentation and examples
  • See if implementing Deref or something for DeviceTreeNode can make calling methods from the Node trait on it nicer.

@m4tx
Copy link
Collaborator

m4tx commented Dec 17, 2025

The old discussion for context: #16 (comment)

I thought of yet another way to solve the code duplication problem. Perhaps we could change the intermediate representation API a little bit to match Fdt more:

  • We could change DeviceTreeNode and DeviceTreeProperty to become internal structures
  • Similarly to FdtNode and FdtProperty, we could create similar structures for the DeviceTree API that would borrow the data from DeviceTree
  • Adding (and perhaps modifying) data could be done using builder structures

This would solve the problems with the trait trickery because the lifetimes would be the same for both APIs, and would probably simplify things with the Reg property getter, for instance. Having a very similar API between in-memory FDT, and our internal representation sounds like an added bonus that simplifies things for the users.

@qwandor qwandor force-pushed the typedaccessors branch 6 times, most recently from 676a613 to 1def694 Compare December 17, 2025 17:21
Base automatically changed from typedaccessors to main December 17, 2025 17:27
@qwandor qwandor force-pushed the trait branch 3 times, most recently from cb648bc to 96a20f3 Compare December 19, 2025 17:39
@qwandor
Copy link
Collaborator Author

qwandor commented Dec 19, 2025

Inspired by your comment, it turns out there's a simpler way: I can implement the trait for &DeviceTreeNode rather than for DeviceTreeNode. That way the lifetimes all seem to work out so far.

@qwandor qwandor force-pushed the trait branch 4 times, most recently from 6f43988 to c052830 Compare December 24, 2025 18:11
@qwandor qwandor changed the base branch from main to validate-fdt December 24, 2025 18:12
@qwandor qwandor changed the title Try adding trait for both node types. Add traits for nodes and properties Dec 24, 2025
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.

2 participants