Getting started
Load a typed config from a file with scarab-config-file. The whole flow is three steps: define your serde model, pick a Discovery spec, load.
1. Add the crates
Scarab isn't published to crates.io — depend on the git repo, like every org consumer does (myco, tarsi, …):
toml
[dependencies]
scarab-config = { git = "ssh://[email protected]/9aia/scarab.git" }
scarab-config-file = { git = "ssh://[email protected]/9aia/scarab.git" }
scarab-config-yaml = { git = "ssh://[email protected]/9aia/scarab.git" }
scarab-config-toml = { git = "ssh://[email protected]/9aia/scarab.git" }
serde = { version = "1", features = ["derive"] }2. Define your config model
Scarab stays generic — your repo owns the Config type:
rust
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct MyConfig {
name: String,
port: u16,
}3. Load it
rust
use scarab_config_file::FileSource;
let cfg: MyConfig = FileSource::for_app("myapp").load()?;FileSource::for_app("myapp") wires the org conventions for you: env var MYAPP_CONFIG, search dirs [".", "~/.config/myapp"], and the standard format pair (YAML preferred, TOML fallback). For myapp it resolves, in order:
$MYAPP_CONFIG— an explicit file path./myapp.yaml,./myapp.yml,./myapp.toml~/.config/myapp/myapp.yaml,.yml,.toml
The first existing file wins. See reference: config port for the full contract and how-to: customize discovery for custom search specs.
Next steps
- Layer configs from several files — merge
~/.config/<name>/with a project file instead of first-match. - Write a template pack — ship rendered config files as a tamias
type: templatepackage. - Deploy a template pack — the driver verbs, variable layers, and uninstall semantics.