Crate id_tree [] [src]

A library for creating and modifying Tree structures.

Overview

In this implementation, the Tree owns all of the Nodes and all inter-Node relationships are managed with NodeIds.

Trees in this library are "just" trees. They do not allow cycles. They do not allow the creation of arbitrary Graph structures. There is no weight associated with edges between Nodes. In addition, each Node can have an arbitrary number of child Nodes.

It is important to note that this library does not support comparison-based Node insertion. In other words, this is not a Binary Search Tree (or any other kind of search tree) library. It is purely a library for storing data in a hierarchical manner. The caller must know the structure that they wish to build and then use this library to do so; this library will not make those structural decisions for you.

Project Goals

  • Allow caller control of as many allocations as possible (through pre-allocation)
  • Fast Node insertion and removal
  • Arbitrary Tree structure creation and manipulation

Non-Goals

  • Arbitrary Graph structure creation and manipulation
  • Comparison-based node insertion of any kind

Drawbacks of this Library

Sadly, Rust's ownership/reference system is sidestepped a bit by this implementation and this can cause issues if the caller doesn't pay attention to what they are doing with NodeIds.

We try to solve these issues with very careful usage of NodeIds so that the caller doesn't have to be bothered (too much) with these concerns.

Please see the Potential NodeId Issues section of the NodeId documentation for more info on what these issues are and how this library attempts to solve them.


Disclaimer: This library should be considered a Work-in-Progress until it reaches v1.0.0. Breaking changes will be avoided at all costs, but until v1.0.0 hits, they are a definite possibility. With that in mind, it would be wise to find a version number that works for you (preferably whatever the current version is when you read this) and stick with it until you are ready to upgrade to the next version.

Structs

Node

A container that wraps data in a given Tree.

NodeBuilder

A Node builder that provides more control over how a Node is created.

NodeId

An identifier used to differentiate between Nodes within a Tree.

Tree

A tree structure consisting of Nodes.

TreeBuilder

A Tree builder that provides more control over how a Tree is created.

Enums

NodeIdError

Enum for all of the possible NodeId errors that could occur.