config/file/source/
mod.rs1pub(crate) mod file;
2pub(crate) mod string;
3
4use std::error::Error;
5use std::fmt::Debug;
6
7use crate::{file::FileStoredFormat, Format};
8
9pub trait FileSource<T>: Debug + Clone
11where
12 T: Format + FileStoredFormat,
13{
14 fn resolve(
15 &self,
16 format_hint: Option<T>,
17 ) -> Result<FileSourceResult, Box<dyn Error + Send + Sync>>;
18}
19
20#[allow(unnameable_types)] pub struct FileSourceResult {
22 pub(crate) uri: Option<String>,
23 pub(crate) content: String,
24 pub(crate) format: Box<dyn Format>,
25}
26
27impl FileSourceResult {
28 pub fn uri(&self) -> &Option<String> {
29 &self.uri
30 }
31
32 pub fn content(&self) -> &str {
33 self.content.as_str()
34 }
35
36 pub fn format(&self) -> &dyn Format {
37 self.format.as_ref()
38 }
39}