use crate::error::ConfigError;
use serde::{Serialize, de::DeserializeOwned};
pub fn print_schema<T>() -> Result<(), ConfigError>
where
T: Serialize + Default + DeserializeOwned,
{
let default = T::default();
let json = serde_json::to_string_pretty(&default).map_err(|e| {
ConfigError::new("Failed to serialise default config to JSON")
.with_kind("SerialisationError")
.with_source(e)
})?;
let toml = toml::to_string_pretty(&default).map_err(|e| {
ConfigError::new("Failed to serialise default config to TOML")
.with_kind("SerialisationError")
.with_source(e)
})?;
println!("--- JSON Example ---\n{json}\n");
println!("--- TOML Example ---\n{toml}");
Ok(())
}