data_modelling_sdk/export/
mod.rs

1//! Export functionality
2//!
3//! Provides exporters for various formats:
4//! - SQL
5//! - JSON Schema
6//! - AVRO
7//! - Protobuf
8//! - ODCS (Open Data Contract Standard) v3.1.0
9//! - PNG
10//! - Decision (MADR-compliant decision records)
11//! - Knowledge (Knowledge Base articles)
12//! - Markdown (for GitHub readability)
13
14pub mod avro;
15#[cfg(feature = "bpmn")]
16pub mod bpmn;
17pub mod cads;
18pub mod decision;
19#[cfg(feature = "dmn")]
20pub mod dmn;
21pub mod json_schema;
22pub mod knowledge;
23pub mod markdown;
24pub mod odcl;
25pub mod odcs;
26pub mod odps;
27#[cfg(feature = "openapi")]
28pub mod openapi;
29#[cfg(feature = "png-export")]
30pub mod png;
31pub mod protobuf;
32pub mod sql;
33
34// anyhow::Result not currently used in this module
35
36/// Result of an export operation.
37///
38/// Contains the exported content and format identifier.
39#[derive(Debug, serde::Serialize, serde::Deserialize)]
40#[must_use = "export results contain the exported content and should be used"]
41pub struct ExportResult {
42    /// Exported content (as string - binary formats will be base64 encoded)
43    pub content: String,
44    /// Format identifier
45    pub format: String,
46}
47
48/// Error during export
49#[derive(Debug, thiserror::Error, serde::Serialize, serde::Deserialize)]
50pub enum ExportError {
51    #[error("Serialization error: {0}")]
52    SerializationError(String),
53    #[error("Validation error: {0}")]
54    ValidationError(String),
55    #[error("Invalid argument: {0}")]
56    InvalidArgument(String),
57    #[error("IO error: {0}")]
58    IoError(String),
59    #[error("Export error: {0}")]
60    ExportError(String),
61    #[error("BPMN export error: {0}")]
62    BPMNExportError(String),
63    #[error("DMN export error: {0}")]
64    DMNExportError(String),
65    #[error("OpenAPI export error: {0}")]
66    OpenAPIExportError(String),
67    #[error("Model not found: {0}")]
68    ModelNotFound(String),
69}
70
71impl From<Box<dyn std::error::Error>> for ExportError {
72    fn from(err: Box<dyn std::error::Error>) -> Self {
73        ExportError::ExportError(err.to_string())
74    }
75}
76
77// Re-export for convenience
78pub use avro::AvroExporter;
79#[cfg(feature = "bpmn")]
80pub use bpmn::BPMNExporter;
81pub use cads::CADSExporter;
82pub use decision::DecisionExporter;
83#[cfg(feature = "dmn")]
84pub use dmn::DMNExporter;
85pub use json_schema::JSONSchemaExporter;
86pub use knowledge::KnowledgeExporter;
87pub use markdown::MarkdownExporter;
88pub use odcl::ODCLExporter;
89pub use odcs::ODCSExporter;
90pub use odps::ODPSExporter;
91#[cfg(feature = "openapi")]
92pub use openapi::OpenAPIExporter;
93#[cfg(feature = "png-export")]
94pub use png::PNGExporter;
95pub use protobuf::ProtobufExporter;
96pub use sql::SQLExporter;