Skip to main content

remodel_core/
lib.rs

1//! # RemodelCore
2//!
3//! Engine for database modeling: build conceptual (Entity-Relationship) models,
4//! normalize them into logical (relational) models, and emit SQL DDL for the
5//! major dialects.
6//!
7//! `remodel-core` is a Rust reimplementation of the modeling engine of
8//! [brModelo](https://github.com/sis4com/brModelo) by Carlos Henrique Cândido.
9//! See the crate `README.md` for credits and licensing.
10//!
11//! The crate is organized in three layers, mirroring the three model "levels"
12//! used in database design:
13//!
14//! - [`models::conceptual`] — Entity-Relationship structures
15//! - [`models::logical`] — relational (table-and-constraint) structures
16//! - [`sql`] — physical DDL generation per [`SqlDialect`](sql::SqlDialect)
17//!
18//! Transformations between levels live in [`transform`], and structural
19//! checks in [`validation`].
20
21#![warn(missing_docs)]
22#![warn(rust_2018_idioms)]
23
24pub mod error;
25pub mod format;
26pub mod models;
27pub mod sql;
28pub mod transform;
29pub mod validation;
30
31pub use error::{Error, Result};
32
33/// Convenient re-exports for downstream users.
34pub mod prelude {
35    pub use crate::error::{Error, Result};
36    pub use crate::models::cardinality::Cardinality;
37    pub use crate::models::conceptual::{
38        Attribute, AttributeKind, ConceptualModel, Entity, EntityId, Relationship,
39        RelationshipId, Specialization, SpecializationKind, Union,
40    };
41    pub use crate::models::logical::{
42        Column, ColumnId, Constraint, ConstraintKind, ForeignKey, LogicalModel, ReferentialAction,
43        Table, TableId,
44    };
45    pub use crate::models::types::DataType;
46    pub use crate::sql::SqlDialect;
47    pub use crate::transform::{ConvertOptions, RelationshipResolution, SpecializationStrategy};
48    pub use crate::validation::{Diagnostic, Severity};
49}
50
51/// Crate version, useful when persisting model files that need a writer tag.
52pub const VERSION: &str = env!("CARGO_PKG_VERSION");