use plugx_input::Input;
use std::fmt::Debug;
use thiserror::Error;
#[cfg(feature = "env")]
pub mod env;
#[cfg(feature = "json")]
pub mod json;
#[cfg(feature = "toml")]
pub mod toml;
#[cfg(feature = "yaml")]
pub mod yaml;
pub mod closure;
pub type BoxedModifierFn =
Box<dyn Fn(&[u8], &mut Input) -> Result<(), ConfigurationParserError> + Send + Sync>;
#[derive(Debug, Error)]
pub enum ConfigurationParserError {
#[error("{parser} with supported formats {supported_format_list:?} could not parse `{data}`")]
Parse {
data: String,
parser: String,
supported_format_list: Vec<String>,
source: anyhow::Error,
},
#[error("Could not found parser")]
ParserNotFound,
}
pub trait ConfigurationParser: Send + Sync + Debug {
fn supported_format_list(&self) -> Vec<String>;
fn try_parse(&self, bytes: &[u8]) -> Result<Input, ConfigurationParserError>;
fn is_format_supported(&self, bytes: &[u8]) -> Option<bool>;
}