Expand description
§kawauso-config
Configuration files for Kawauso applications
This crate loads the configuration files of Kawauso applications. Every application finds, loads, and deserializes its configuration file in the same way, and reports failures with the same clear errors.
Loader is the entry point of the crate. A constructor selects the source
of the configuration, and load deserializes the configuration into a type
that the caller defines.
The source can be a search. An application whose configuration belongs to a
project uses ancestors, which walks from the working directory up to the
root of the file system. An application whose configuration belongs to a user
uses user, which reads the directory that the platform defines for the
configuration of a user.
A search derives the name of the configuration file from the name of the
application. The name becomes part of a path, so an ApplicationName
holds 1 to 250 ASCII letters, ASCII digits, and hyphens, and it is not the
name of a device on Windows. The application creates the name with parse,
which fails for a value that does not obey these rules. A search that takes
the name therefore cannot fail because of it.
Some projects do not keep the configuration file in the directory that the
search reads. A tool that belongs to GitHub, for example, keeps the file in
.github. An AncestorsSearch adds such a subdirectory to ancestors.
The search then reads that subdirectory in each directory on its way up.
An application that owns a directory of its own in .config uses the
dot-config convention instead. dot_config on the search reads the file
.config/<application>.toml and the file config.toml in
.config/<application>, in each directory of the walk. The convention fixes
the directory and the name of the file, so the application names itself once.
§Usage
use serde::Deserialize;
use kawauso_config::Loader;
#[derive(Deserialize)]
struct Configuration {
port: u16,
}
let configuration: Configuration = Loader::contents("port = 8080").load()?;
assert_eq!(configuration.port, 8080);§License
Copyright (c) 2026 Aonyx B.V.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Re-exports§
pub use self::loader::AncestorsSearch;pub use self::loader::ApplicationName;pub use self::loader::Loader;