config_maint/file/source/
string.rs

1use std::error::Error;
2use std::result;
3use std::str::FromStr;
4
5use super::{FileFormat, FileSource};
6use source::Source;
7
8/// Describes a file sourced from a string
9#[derive(Clone, Debug)]
10pub struct FileSourceString(String);
11
12impl<'a> From<&'a str> for FileSourceString {
13    fn from(s: &'a str) -> Self {
14        FileSourceString(s.into())
15    }
16}
17
18impl FileSource for FileSourceString {
19    fn resolve(
20        &self,
21        format_hint: Option<FileFormat>,
22    ) -> Result<(Option<String>, String, FileFormat), Box<dyn Error + Send + Sync>> {
23        Ok((
24            None,
25            self.0.clone(),
26            format_hint.expect("from_str requires a set file format"),
27        ))
28    }
29}