Skip to content

andreimerlescu/rusty-figtree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

99 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

rusty-figtree

A layered runtime configuration system for Rust, inspired by the Go figtree package. Supports multiple configuration sources with explicit priority resolution, per-key validators, per-key callbacks, and live mutation tracking via channels.

Repository Structure

rusty-figtree/
β”œβ”€β”€ Cargo.toml           # workspace root β€” ties both crates together
β”œβ”€β”€ VERSION              # single version file for both crates
β”œβ”€β”€ build.rs             # reads VERSION, exposes APP_VERSION at compile time
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ figtree/             # primary library crate
β”‚   β”œβ”€β”€ Cargo.toml
β”‚   β”œβ”€β”€ README.md
β”‚   └── src/
β”‚       β”œβ”€β”€ lib.rs
β”‚       β”œβ”€β”€ error.rs
β”‚       β”œβ”€β”€ tree.rs
β”‚       β”œβ”€β”€ fig.rs
β”‚       β”œβ”€β”€ mutation.rs
β”‚       β”œβ”€β”€ priority.rs
β”‚       β”œβ”€β”€ rules.rs
β”‚       β”œβ”€β”€ validators.rs
β”‚       β”œβ”€β”€ callbacks.rs
β”‚       β”œβ”€β”€ sources/
β”‚       β”‚   β”œβ”€β”€ mod.rs
β”‚       β”‚   β”œβ”€β”€ env.rs
β”‚       β”‚   β”œβ”€β”€ cli.rs
β”‚       β”‚   β”œβ”€β”€ yaml.rs
β”‚       β”‚   β”œβ”€β”€ json.rs
β”‚       β”‚   β”œβ”€β”€ ini.rs
β”‚       β”‚   └── embedded.rs
β”‚       └── tests/
β”‚           β”œβ”€β”€ tree_test.rs
β”‚           β”œβ”€β”€ validators_test.rs
β”‚           β”œβ”€β”€ priority_test.rs
β”‚           β”œβ”€β”€ sources_test.rs
β”‚           └── callbacks_test.rs
└── figtree-derive/      # procedural macro crate
    β”œβ”€β”€ Cargo.toml
    β”œβ”€β”€ README.md
    └── src/
        └── lib.rs

Two Crates, One Repository

This repository is a Cargo workspace containing two crates that are always versioned, built, tested, and published together.

figtree is the library your application depends on at runtime. figtree-derive is the procedural macro crate the Rust compiler consumes at build time to expand the #[derive(Figtree)] decorator. End users never reference figtree-derive directly in their own Cargo.toml β€” it is re-exported transparently by figtree.

Priority Resolution

figtree resolves configuration values in a fixed priority order. This order is inspired by PEMDAS β€” just as multiplication always precedes addition regardless of left-to-right reading, CLI flags always precede environment variables regardless of declaration order.

CLI flags
  > Environment Variables
    > Configuration Files (in load order)
      > Programmatic Store()
        > Default Values

The source that wins is the one highest in this hierarchy that has a value defined. A default only speaks when nothing above it does.

Feature Flags

Feature       What It Enables
-------       ---------------
std           Standard library support (enabled by default)
env           Environment variable source (enabled by default)
yaml          YAML config file source via serde_yaml
json          JSON config file source via serde_json
ini           INI config file source via rust-ini
cli           CLI flag source via clap
async         Async mutation channel via tokio
embedded      Bare metal source support, implies no_std

Versioning

Both crates share a single VERSION file at the repository root. The build.rs script reads this file at compile time and exposes the version as APP_VERSION. Bumping the version with the bump tool updates both crates atomically.

bump -patch -write
cargo build --release

License

Apache 2.0

About

A rust πŸ¦€ port of the figtree 🐿️ written in Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages