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
20pub struct FileSourceResult {
21 pub(crate) uri: Option<String>,
22 pub(crate) content: String,
23 pub(crate) format: Box<dyn Format>,
24}
25
26impl FileSourceResult {
27 pub fn uri(&self) -> &Option<String> {
28 &self.uri
29 }
30
31 pub fn content(&self) -> &str {
32 self.content.as_str()
33 }
34
35 pub fn format(&self) -> &dyn Format {
36 self.format.as_ref()
37 }
38}