Expand description
Cast — Eloquent-shaped ORM for Anvil. Facade crate.
ⓘ
use cast::{Model, Pool};
#[derive(cast::Model)]
#[table("users")]
pub struct User {
pub id: i64,
pub name: String,
pub email: String,
}
let users = User::query()
.where_eq(User::columns().email(), "x@y.com".to_string())
.get(&pool).await?;Re-exports§
Modules§
- chrono
- Chrono: Date and Time for Rust
- column
- Typed column references. Generated by
#[derive(Model)]. - error
- Cast-specific errors. Converted to
anvil::Errorat the HTTP layer. - inventory
- github crates-io docs-rs
- migration
- Migration runner. Each migration is a Rust value with
up/downmethods. - model
- The
Modeltrait — every Cast model implements this. - paginator
- Pagination — mirrors Laravel’s
LengthAwarePaginator. - pool
- Database connection pool(s).
- query
- Query builder. Typed where clauses on top of sea-query + sqlx.
- relation
- Relationship definitions.
RelationDefis implemented by zero-sized types generated by#[has_many]/#[belongs_to]attribute parsing. - schema
- Schema builder. Used in migrations:
Schema::create("users", |t| ...). - sea_
query - sea_
query_ binder - Driver library for using SeaQuery with SQLx
- sqlx
- The async SQL toolkit for Rust, built with ❤️ by the LaunchBadge team.
Macros§
- migration
- Closure-style migration — Laravel’s
Schema::create('posts', function (Blueprint $t) { ... })ported to Rust. - scopes
- Define chainable Eloquent-style local scopes on a model’s query builder.
Structs§
- Belongs
To - Column
- Column
Def - Column
Ref - Untyped column reference for the query builder’s internal use.
- Connection
- One named connection — a write pool plus zero-or-more read replicas.
- Connection
Manager - Resolves named connections — the centerpiece of Cast’s multi-database support.
- HasMany
- HasOne
- Loaded
- Wrapper for eager-loaded query results. Generic over the loading shape;
in practice a concrete
LoadedUserWithPoststype is generated per derive. - Migration
Runner - Migration
Status - Returned by
migrate:status. - Model
Registration - Inventory record for
#[derive(Model)]. Lets boost/MCP and other introspection tools list every model registered at compile time. - Paginator
- Page-aware paginator. Produced by
QueryBuilder::paginate(per_page, page, pool). - Query
Builder - Schema
- Table
- A table definition assembled inside the build closure.
Enums§
- Driver
- Which database engine a connection is talking to.
- Error
- Pool
- Driver-tagged pool. Variant tells you which backing sqlx type is live.
Traits§
Functions§
- connect
- Connect to a database, dispatching by URL scheme.
- registered_
models
Type Aliases§
Derive Macros§
- sea_