pub mod decompile;
mod error;
mod format;
pub mod integrate;
mod jsonld;
mod kpar;
pub mod metadata;
pub mod model;
pub mod recompile;
mod xmi;
mod yaml;
pub use decompile::{DecompileResult, decompile, decompile_with_source};
pub use error::InterchangeError;
pub use format::{FormatCapability, ModelFormat};
pub use integrate::{
apply_metadata_to_host, model_from_database, model_from_symbols, symbols_from_model,
};
pub use jsonld::JsonLd;
pub use kpar::{Kpar, KparManifest};
pub use metadata::{
Dependency, ElementMeta, ImportMetadata, PackageMetadata, ProjectMetadata, SourceInfo,
};
pub use model::{
Element, ElementId, ElementKind, Model, ModelMetadata, Relationship, RelationshipKind,
};
pub use recompile::{restore_element_ids, restore_ids_from_symbols};
pub use xmi::Xmi;
pub use yaml::Yaml;
pub fn supported_extensions() -> &'static [&'static str] {
&["xmi", "kpar", "jsonld", "json", "yaml", "yml"]
}
pub fn detect_format(path: &std::path::Path) -> Option<Box<dyn ModelFormat>> {
let ext = path.extension()?.to_str()?;
match ext.to_lowercase().as_str() {
"xmi" => Some(Box::new(Xmi)),
"kpar" => Some(Box::new(Kpar)),
"jsonld" | "json" => Some(Box::new(JsonLd)),
"yaml" | "yml" => Some(Box::new(Yaml)),
_ => None,
}
}
pub fn detect_format_from_mime(mime: &str) -> Option<Box<dyn ModelFormat>> {
match mime {
"application/xmi+xml" | "application/xml" => Some(Box::new(Xmi)),
"application/zip" | "application/kpar" => Some(Box::new(Kpar)),
"application/ld+json" | "application/json" => Some(Box::new(JsonLd)),
"application/x-yaml" | "text/yaml" => Some(Box::new(Yaml)),
_ => None,
}
}