#[cfg(feature = "converters")]
pub mod json;
#[cfg(feature = "converters")]
pub mod toml;
#[cfg(feature = "converters")]
pub mod yaml;
pub mod toon;
#[cfg(all(test, feature = "converters"))]
mod converter_props;
#[cfg(feature = "converters")]
pub use json::{json_to_document, json_to_dx};
#[cfg(feature = "converters")]
pub use toml::{toml_to_document, toml_to_dx};
pub use toon::{dx_to_toon, toon_to_dx};
#[cfg(feature = "converters")]
pub use yaml::yaml_to_dx;
pub trait ToDx {
fn to_dx(&self) -> Result<String, String>;
}
#[cfg(feature = "converters")]
pub fn convert_to_dx(input: &str, format: &str) -> Result<String, String> {
match format.to_lowercase().as_str() {
"json" => json_to_dx(input),
"yaml" | "yml" => yaml_to_dx(input),
"toon" => toon_to_dx(input),
"toml" => toml_to_dx(input),
_ => Err(format!("Unsupported format: {}", format)),
}
}
#[cfg(not(feature = "converters"))]
pub fn convert_to_dx(input: &str, format: &str) -> Result<String, String> {
match format.to_lowercase().as_str() {
"toon" => toon_to_dx(input),
_ => Err(format!(
"Format '{}' requires the 'converters' feature. Only 'toon' is available without it.",
format
)),
}
}