5 releases

0.2.2 May 31, 2024
0.2.1 May 30, 2024
0.2.0 May 30, 2024
0.1.1 May 30, 2024
0.1.0 May 30, 2024

#195 in Configuration

Download history 380/week @ 2024-05-27 3/week @ 2024-06-03 2/week @ 2024-06-10

385 downloads per month

Apache-2.0

41KB
551 lines

metre: The rust configuration loader

AKA: #[derive(Config)]

build unit-tests integration-tests docs

What is it?

metre is a configuration loader for Rust that allows you to load configurations from a variety of formats such as toml, json, jsonc and yaml

It also supports a variety of sources such as program defaults, env variables, files, and urls.

Focus

metre focus is to provide a declarative and type-safe way to load configurations in Rust.

How?

metre works by defining a struct that implements the Config trait, usually via the #[derive(Config)] macro.

Under the hood metre creates deep partial version of the struct to accumulate the configuration from different sources.

Once all the configuration is accumulated, you can access the final configuration as the defined struct. If the sum of all sources does not comply with the required properties, metre will return an error.

Install

cargo add metre

Docs

https://docs.rs/metre

Dependencies

~0.7–13MB
~153K SLoC