toasty_core/schema/
app.rs

1//! Application-level schema definitions for models, fields, relations, and indices.
2//!
3//! This module contains the types that represent a Toasty schema from the
4//! application's perspective: models with named fields, relationships between
5//! models, primary keys, indices, and constraints. This is the layer that Rust
6//! code interacts with; the separate [`super::db`] module represents the
7//! physical database schema (tables, columns), and [`super::mapping`] bridges
8//! the two.
9//!
10//! # Key types
11//!
12//! - [`Schema`] -- the top-level container holding all registered models.
13//! - [`Model`] -- a single model, which can be a [`ModelRoot`] (backed by a
14//!   database table), an [`EmbeddedStruct`], or an [`EmbeddedEnum`].
15//! - [`Field`] -- one field on a model, identified by a [`FieldId`].
16//! - [`BelongsTo`], [`HasMany`], [`HasOne`] -- relation types.
17//! - [`Index`] -- a secondary index on a model's fields.
18//! - [`PrimaryKey`] -- a model's primary key definition.
19//!
20//! # Examples
21//!
22//! ```ignore
23//! use toasty_core::schema::app::Schema;
24//!
25//! // Schemas are typically constructed via the derive macro or `Schema::from_macro`.
26//! let schema = Schema::default();
27//! assert_eq!(schema.models().count(), 0);
28//! ```
29
30mod arg;
31pub use arg::Arg;
32
33mod auto;
34pub use auto::{AutoStrategy, UuidVersion};
35
36mod constraint;
37pub use constraint::{Constraint, ConstraintLength};
38
39mod embedded;
40pub use embedded::Embedded;
41
42mod field;
43pub use field::{Field, FieldId, FieldName, FieldPrimitive, FieldTy, SerializeFormat};
44
45mod fk;
46pub use fk::{ForeignKey, ForeignKeyField};
47
48mod index;
49pub use index::{Index, IndexField, IndexId};
50
51mod model;
52pub use model::{
53    EmbeddedEnum, EmbeddedStruct, EnumVariant, Model, ModelId, ModelRoot, ModelSet, VariantId,
54};
55
56mod pk;
57pub use pk::PrimaryKey;
58
59mod relation;
60pub use relation::{BelongsTo, HasMany, HasOne};
61
62mod schema;
63pub use schema::{Resolved, Schema};
64
65use super::Name;