Skip to main content

tuwunel_core/config/
format.rs

1use figment::providers::Format;
2use serde::de::DeserializeOwned;
3use toml::de::{Error as TomlError, from_str as from_toml_str};
4
5/// TOML data format for figment's file and string providers.
6///
7/// figment's own provider is gated behind `toml 0.8`, a second copy of the toml
8/// crate family alongside the `toml 1.x` the workspace uses. Supplying the
9/// format here keeps figment's file, nesting and profile machinery while
10/// parsing through the workspace crate.
11pub(super) struct Toml;
12
13impl Format for Toml {
14	type Error = TomlError;
15
16	const NAME: &'static str = "TOML";
17
18	fn from_str<T: DeserializeOwned>(text: &str) -> Result<T, Self::Error> { from_toml_str(text) }
19}