Module app

Module app 

Source
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.
BelongsTo
The owning side of a relationship. Stores the foreign key that references another model’s primary key.
ConstraintLength
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.
EmbeddedEnum
An embedded enum model stored in the parent table via a discriminant column and optional per-variant data columns.
EmbeddedStruct
An embedded struct model whose fields are flattened into its parent model’s database table.
EnumVariant
One variant of an EmbeddedEnum.
Field
A single field within a model.
FieldId
Uniquely identifies a Field within a schema.
FieldName
The name of a field, with separate application and storage representations.
FieldPrimitive
A primitive (non-relation, non-embedded) field type.
ForeignKey
A foreign key linking one model’s fields to another model’s primary key.
ForeignKeyField
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.
IndexField
A single field entry within an Index.
IndexId
Uniquely identifies an Index within a schema.
ModelId
Uniquely identifies a Model within a Schema.
ModelRoot
A root model backed by its own database table.
ModelSet
An ordered collection of Model definitions.
PrimaryKey
The primary key definition for a root model.
Schema
The top-level application schema, containing all registered models.
VariantId
Identifies a specific variant within an EmbeddedEnum model.

Enums§

AutoStrategy
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::Projection through the application schema.
SerializeFormat
The serialization format used to store a field value in the database.
UuidVersion
UUID version to use for auto-generated UUID fields.