Expand description
Application-level (model-oriented) schema definitions. Application-level schema definitions for models, fields, relations, and indices.
This module contains the types that represent a Toasty schema from the
application’s perspective: models with named fields, relationships between
models, primary keys, indices, and constraints. This is the layer that Rust
code interacts with; the separate [super::db] module represents the
physical database schema (tables, columns), and [super::mapping] bridges
the two.
§Key types
Schema– the top-level container holding all registered models.- [
Model] – a single model, which can be a [ModelRoot] (backed by a database table), an [EmbeddedStruct], or an [EmbeddedEnum]. - [
Field] – one field on a model, identified by a [FieldId]. - [
BelongsTo], [HasMany], [HasOne] – relation types. - [
Index] – a secondary index on a model’s fields. - [
PrimaryKey] – a model’s primary key definition.
§Examples
ⓘ
use toasty_core::schema::app::Schema;
// Schemas are typically constructed via the derive macro or `Schema::from_macro`.
let schema = Schema::default();
assert_eq!(schema.models().count(), 0);Structs§
- Arg
- A named, typed argument used in query parameterization.
- Belongs
To - The owning side of a relationship. Stores the foreign key that references another model’s primary key.
- Constraint
Length - A length constraint for string fields.
- Embedded
- A reference to an embedded model (struct or enum) that is stored inline within its parent model’s table rather than in a separate table.
- Embedded
Enum - An embedded enum model stored in the parent table via a discriminant column and optional per-variant data columns.
- Embedded
Struct - An embedded struct model whose fields are flattened into its parent model’s database table.
- Enum
Variant - One variant of an
EmbeddedEnum. - Field
- A single field within a model.
- FieldId
- Uniquely identifies a
Fieldwithin a schema. - Field
Name - The name of a field, with separate application and storage representations.
- Field
Primitive - A primitive (non-relation, non-embedded) field type.
- Foreign
Key - A foreign key linking one model’s fields to another model’s primary key.
- Foreign
KeyField - One column-pair within a
ForeignKey. - HasMany
- The inverse side of a one-to-many relationship.
- HasOne
- The inverse side of a one-to-one relationship.
- Index
- An index defined on a model’s fields.
- Index
Field - A single field entry within an
Index. - IndexId
- Uniquely identifies an
Indexwithin a schema. - ModelId
- Uniquely identifies a
Modelwithin aSchema. - Model
Root - A root model backed by its own database table.
- Model
Set - An ordered collection of
Modeldefinitions. - Primary
Key - The primary key definition for a root model.
- Schema
- The top-level application schema, containing all registered models.
- Variant
Id - Identifies a specific variant within an
EmbeddedEnummodel.
Enums§
- Auto
Strategy - Strategy for automatically populating a field’s value on insert.
- Constraint
- A validation constraint applied to a field.
- FieldTy
- The type of a
Field, distinguishing primitives, embedded types, and relation variants. - Model
- A model in the application schema.
- Resolved
- The result of resolving a
stmt::Projectionthrough the application schema. - Serialize
Format - The serialization format used to store a field value in the database.
- Uuid
Version - UUID version to use for auto-generated UUID fields.