brk_traversable_derive

Crates.iobrk_traversable_derive
lib.rsbrk_traversable_derive
version0.1.0-beta.0
created_at2025-12-18 22:16:38.342291+00
updated_at2026-01-25 13:21:58.021833+00
descriptionDerive for brk_vec's used in BRK
homepagehttps://bitcoinresearchkit.org
repositoryhttps://github.com/bitcoinresearchkit/brk
max_upload_size
id1993651
size21,201
(nym21)

documentation

README

brk_traversable_derive

Proc-macro for deriving the Traversable trait on data structures.

What It Enables

Automatically generate tree traversal and export iteration for structs, eliminating boilerplate when working with hierarchical data that needs serialization or inspection.

Key Features

  • Automatic tree building: Converts struct fields into TreeNode::Branch hierarchies
  • Export iteration: Generates iter_any_exportable() to walk all exportable vectors
  • Field attributes: #[traversable(skip)] to exclude fields, #[traversable(flatten)] to merge nested structures
  • Option support: Gracefully handles Option<T> fields
  • Generic-aware: Properly bounds generic parameters with Traversable + Send + Sync

Core API

#[derive(Traversable)]
struct MyData {
    pub metrics: MetricsCollection,
    #[traversable(flatten)]
    pub nested: NestedData,
    #[traversable(skip)]
    internal: Cache,
}

Generated Methods

  • to_tree_node(&self) -> TreeNode - Build navigable tree structure
  • iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> - Iterate all exportable vectors
Commit count: 1045

cargo fmt