How billyevans/tst works
Project type and purpose
• This is a Rust library crate (“tst”) implementing a ternary search tree (TST) data structure, with two public types: TSTMap and TSTSet.
• It provides insertion, lookup, prefix‐search, wildcard search, and longest‐prefix operations, with an API modeled after Rust’s standard collections.
File structure
• Top-level project files: Cargo.toml, README.md, LICENSE, CI configs (.travis.yml, .github/…/rust.yml), deployment scripts (deploy-docs.sh, deploy.sh), coverage setup (install-kcov.sh).
• benches/: benchmark driver (bench.rs)
• examples/: sample programs demonstrating usage (callback.rs, dict.rs)
• src/: core library modules
• lib.rs – crate root (public API exports, pub mod declarations)
• .rs – TSTMap implementation
• set.rs – TSTSet implementation (wraps TSTMap or uses same internals)
• node.rs – internal Node struct, children pointers (low, eq, high)
• traverse.rs – iterator implementations (prefix_iter, wildcard_iter)
• tests/: unit tests for map and set modules
README for additional insights
• It confirms core functionality (map and set, wildcard/prefix iterators, longest_prefix).
• References Wikipedia’s TST design.
• Shows code snippets of public API usage.
• User Application (examples, benchmarks, client code)
• tst Crate Public API
– TSTMap
– TSTSet
• Internal Library Modules
– Node (ternary node data structure)
– Traverse (iterator logic for wildcard and prefix)
• External Dependencies
– Rust std::collections (for trait definitions, but minimal external crates)
• CI/CD Pipeline
– GitHub Actions (.github/workflows/rust.yml)
– Travis CI (.travis.yml)
– Coverage (install-kcov.sh, Coveralls)
– Docs Deployment (deploy-docs.sh)
– Crates.io Publishing (deploy.sh)
• User code → calls → Public API (TSTMap / TSTSet)
• Public API → delegates to → Internal Modules (map.rs uses node.rs; map.rs and set.rs call traverse.rs for iterators)
• Node ↔ children pointers → forms the tree data structure
• CI pipeline → triggers → build → tests → benchmarks → documentation → deploy
c. Important architectural patterns
• Modular separation: public API vs. internal implementation
• Iterator pattern: traverse.rs defines Iterator traits for prefix and wildcard searches
• Encapsulation: node.rs is not exposed; only accessed by map/set/traverse
• Layered design: Data storage (node) at the bottom, data structures (map, set) in the middle, user API at the top
d. Technologies, frameworks, libraries
• Rust language and Cargo build system
• GitHub Actions and Travis CI for continuous integration
• Kcov and Coveralls for coverage reporting
• docs.rs/GitHub Pages for documentation
Detailed capturing of essential architectural elements
• Do not omit tests, benchmarks, and CI—they form part of the project’s delivery pipeline.
• How node.rs underpins map.rs and set.rs, and how traverse.rs wraps traversal logic.
• Crate root (lib.rs) exports, and how the public macros (tstmap!) connect to the API.