schema_config_toml/parser.rs
1use schema_core::ParseFrom;
2
3#[derive(thiserror::Error, Debug)]
4pub enum ParseError {
5 // `toml` already renders a precise, annotated snippet (line/column + a caret
6 // under the offending span). Pass it through verbatim rather than prefixing
7 // it — a prefix only mangles that snippet's first line.
8 #[error("{0}")]
9 Serde(#[from] toml::de::Error),
10}
11
12impl<T: AsRef<str>> ParseFrom<T> for super::ConfigToml {
13 type Error = ParseError;
14
15 fn try_parse(value: T) -> Result<Self, Self::Error> {
16 let result = toml::from_str(value.as_ref())?;
17 Ok(result)
18 }
19}