storm_config/file/source/
mod.rs

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