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
impl Builder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Builder with default settings.
§Examples
use toasty_core::schema::Builder;
let builder = Builder::new();Sourcepub fn table_name_prefix(&mut self, prefix: &str) -> &mut Self
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_");Sourcepub fn build(&self, app: Schema, db: &Capability) -> Result<Schema>
pub fn build(&self, app: Schema, db: &Capability) -> Result<Schema>
Builds the complete Schema from the given app schema and driver
capabilities.
This method:
- Verifies each model against the driver’s capabilities
- Generates field-level constraints (e.g.,
VARCHARlength limits) - Creates database tables, columns, and indices
- Builds the bidirectional mapping between models and tables
- 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§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more