storm-config 0.28.151

A crate containing the configuration structure and utilities used by Storm Software monorepos.
Documentation
pub mod file;
pub mod string;

use crate::{file::FileStoredFormat, Format};
use std::error::Error;
use std::fmt::Debug;

/// Describes where the file is sourced
pub trait FileSource<T>: Debug + Clone
where
  T: Format + FileStoredFormat,
{
  fn resolve(
    &self,
    format_hint: Option<T>,
  ) -> Result<FileSourceResult, Box<dyn Error + Send + Sync>>;
}

pub struct FileSourceResult {
  pub(crate) uri: Option<String>,
  pub(crate) content: String,
  pub(crate) format: Box<dyn Format>,
}

impl FileSourceResult {
  pub fn uri(&self) -> &Option<String> {
    &self.uri
  }

  pub fn content(&self) -> &str {
    self.content.as_str()
  }

  pub fn format(&self) -> &dyn Format {
    self.format.as_ref()
  }
}