refactor!: Store node ID in TreeUpdate, not accesskit::Node
#132
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.
Reasons to make this change:
Nodecan deriveDefault, which makes structure initialization more standard. Note: To allow this,Rolealso derivesDefault, with a default variant ofUnknown. But I really didn't want to makeNodeIdderiveDefault, since that would mean allowing a zero ID, and multiple nodes with zero IDs would be an invalid tree.accesskit_consumer), the node IDs are already stored as keys in the map. So storing the IDs in theNodestruct as well is redundant.NodeProviderthat defines getter methods for all of the node fields. Theaccesskit::Nodestruct, which I will probably rename, will implement this trait, but other implementations will be encouraged, for the sake of optimization. We will have to trust these implementations to be immutable snapshots, i.e. all tree changes must be done by passing new nodes to the adapter in aTreeUpdate. Forcing the node ID to be static, i.e. outside of the future trait, will eliminate one possible way that a broken provider could break the tree.Unfortunately, this refactor requires lots of changes to test code, but I think it's worthwhile.