Expand description
§lintel-config
Configuration types and loader for Lintel. Defines the lintel.toml schema, parses config files, and provides utilities for schema URI rewriting and path resolution.
§Features
- Config types —
ConfigandOverridestructs with serde deserialization and JSON Schema generation via schemars - Hierarchical loading — walks up the directory tree merging
lintel.tomlfiles untilroot = true - URI rewriting — prefix-based rewrite rules with longest-prefix-wins semantics
//path resolution — resolve//-prefixed paths relative to the config directory- Schema generation — generates the JSON Schema for
lintel.toml(used at build time bylintel-checkand as a standalone binary)
§Usage
use lintel_config::{find_and_load, apply_rewrites, resolve_double_slash};
// Load config by walking up from a directory
let config = find_and_load(std::path::Path::new("."))
.unwrap()
.unwrap_or_default();
// Check for custom schema mappings
if let Some(url) = config.find_schema_mapping("src/config.json", "config.json") {
println!("Schema: {url}");
}
// Apply rewrite rules and resolve // paths
let uri = apply_rewrites("http://localhost:8000/schema.json", &config.rewrite);
let uri = resolve_double_slash(&uri, std::path::Path::new("/project"));
drop(uri);§Standalone binary
cargo run -p lintel-configPrints the JSON Schema for lintel.toml to stdout.
§License
Apache-2.0
Structs§
Functions§
- apply_
rewrites - Apply rewrite rules to a schema URI. If the URI starts with any key in
rewrites, that prefix is replaced with the corresponding value. The longest matching prefix wins. - find_
and_ load - Search for
lintel.tomlfiles starting fromstart_dir, walking up. Merges all configs found until one withroot = trueis hit (inclusive). Returns the merged config, orNoneif no config file was found. - find_
config_ path - Find the nearest
lintel.tomlstarting fromstart_dir, walking upward. Returns the path tolintel.toml, orNoneif not found. - load
- Load config from the current working directory (walking upward).
- resolve_
double_ slash - Resolve a
//-prefixed path relative to the given root directory (the directory containinglintel.toml). Non-//paths are returned unchanged. - schema
- Generate the JSON Schema for
lintel.tomlas aserde_json::Value.