Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

Constructs a Schema from an app-level schema and driver capabilities.

The builder generates the database-level schema (tables, columns, indices) and the mapping layer that connects app fields to database columns. Call build to produce the final, validated Schema.

§Examples

use toasty_core::schema::Builder;

let schema = Builder::new()
    .table_name_prefix("myapp_")
    .build(app_schema, &capability)
    .expect("valid schema");

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Creates a new Builder with default settings.

§Examples
use toasty_core::schema::Builder;

let builder = Builder::new();
Source

pub fn table_name_prefix(&mut self, prefix: &str) -> &mut Self

Sets a prefix that will be prepended to all generated table names.

This is useful for multi-tenant setups or avoiding name collisions.

§Examples
use toasty_core::schema::Builder;

let mut builder = Builder::new();
builder.table_name_prefix("myapp_");
Source

pub fn build(&self, app: Schema, db: &Capability) -> Result<Schema>

Builds the complete Schema from the given app schema and driver capabilities.

This method:

  1. Verifies each model against the driver’s capabilities
  2. Generates field-level constraints (e.g., VARCHAR length limits)
  3. Creates database tables, columns, and indices
  4. Builds the bidirectional mapping between models and tables
  5. Validates the resulting schema
§Errors

Returns an error if the schema is invalid (e.g., duplicate index names, unsupported types, missing references).

§Examples
use toasty_core::schema::Builder;

let schema = Builder::new()
    .build(app_schema, &capability)?;

Trait Implementations§

Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Builder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.