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