Crates.io | arctree |
lib.rs | arctree |
version | 0.1.0 |
source | src |
created_at | 2024-04-06 20:48:38.999198 |
updated_at | 2024-04-06 20:48:38.999198 |
description | A 'DOM-like' tree implemented using atomic reference counting |
homepage | |
repository | https://github.com/sehnryr/arctree |
max_upload_size | |
id | 1198550 |
size | 42,485 |
arctree is a "DOM-like" tree implemented using atomic reference counting.
This is a fork of rctree.
"DOM-like" here means that data structures can be used to represent the parsed content of an HTML or XML document, like the DOM does, but don't necessarily have the exact same API as the DOM. That is:
The lifetime of nodes is managed through atomic reference counting. To avoid reference cycles which would cause memory leaks, the tree is asymmetric: each node holds optional strong references to its next sibling and first child, but only optional weak references to its parent, previous sibling, and last child.
Nodes are destroyed as soon as there is no strong reference left to them. The structure is such that holding a reference to the root is sufficient to keep the entire tree alive. However, if for example the only reference that exists from outside the tree is one that you use to traverse it, you will not be able to go back "up" the tree to ancestors and previous siblings after going "down", as those nodes will have been destroyed.
Weak references to destroyed nodes are treated as if they were not set at all. (E.g. a node can become a root when its parent is destroyed.)
Since nodes are aliased (have multiple references to them),
RwLock
is used for interior mutability.
Advantages:
Node
user-visible type to manipulate the tree, with methods.Disadvantages:
The current MSRV is 1.49.0 due to the parking_lot
dependency.
arctree is licensed under the MIT License.