Skip to main content

Crate tagtree

Crate tagtree 

Source
Expand description

Organize application data with hierarchical, slash-separated tags.

tagtree is useful for bookmarks, documents, tasks, notes, and other items that can belong to more than one nested category. Use TagTree when the library should keep each item’s complete tag assignment in sync:

use tagtree::{normalize_paths, TagTree};

let mut tree = TagTree::<u64>::new();
tree.set_tags(&42, normalize_paths(["work/rust", "favorite"])?)?;

assert_eq!(tree.items_under("work")?, vec![42]);
assert_eq!(tree.tags_for(&42), vec!["favorite", "work/rust"]);

A path such as work/rust/async is stored as a tree. Queries on work include items assigned to any descendant, while tags_for reports only the item’s actual assignments. An item may appear in several branches at once. Untagged TagTree items are kept at the empty root path and can be queried with items_under("").

The path module provides path validation and normalization helpers for external input.

Re-exports§

pub use path::TagPathError;
pub use path::is_within;
pub use path::normalize_path;
pub use path::normalize_paths;
pub use path::validate_path;

Modules§

path
Helpers for slash-separated tag paths.

Structs§

ItemTags
An item’s current tags returned after a subtree mutation.
TagNode
An owned read-only node in a path tree snapshot.
TagTree
A hierarchical collection of items and their tag paths.
TagTreeSummary
A read-only summary of a tag tree.

Enums§

Error
Errors returned by the public tag-tree and path-tree operations.

Type Aliases§

Result
The result type used by public mutating and querying operations.