Cargo Features
afastorm uses Cargo features to select database drivers, derive support, migrations, and optional
SQLx-compatible Rust types. Feature names and dependencies below match the crate’s Cargo.toml.
Defaults
The default features are:
derive
sqlite
For PostgreSQL-only applications, disable defaults and enable postgres instead. When using
default-features = false, enable every capability the application needs explicitly.
Feature reference
| Feature | Default | Enables | Notes |
|---|---|---|---|
derive | Yes | #[derive(Model)] via afastorm-derive | Turn off if implementing Model manually. |
sqlite | Yes | Native SQLx SQLite driver | Used by Orm::connect for sqlite: URLs. |
postgres | No | Native SQLx PostgreSQL driver | Used by Orm::connect for postgres:// and postgresql:// URLs. |
migrate | No | Migration API and afastorm CLI | The CLI binary is unavailable without this feature. |
uuid | No | uuid::Uuid model/query support | Enable alongside the selected driver. |
chrono | No | chrono date/time model/query types | Provides NaiveDate, NaiveTime, NaiveDateTime, and supported DateTime variants. |
time | No | time crate date/time model/query types | Provides Date, Time, PrimitiveDateTime, and OffsetDateTime. |
rust_decimal | No | rust_decimal::Decimal | SQLite stores the decimal text representation; PostgreSQL uses NUMERIC. |
bigdecimal | No | bigdecimal::BigDecimal | SQLite stores the decimal text representation; PostgreSQL uses NUMERIC. |
ipnetwork | No | std::net::IpAddr and ipnetwork::IpNetwork | Also enables the postgres driver feature. |
ipnet | No | std::net::IpAddr and ipnet::IpNet | Also enables the postgres driver feature. |
mac_address | No | mac_address::MacAddress | Also enables the postgres driver feature. |
bit-vec | No | bit_vec::BitVec | Also enables the postgres driver feature. |
JSON support is always available through serde_json::Value; there is no separate afastorm json
feature. On SQLite, JSON model values are serialized as text in a TEXT column and parsed when
read. On PostgreSQL, they map to JSONB. See SQLite Types and
PostgreSQL Types.
The ipnetwork, ipnet, mac_address, and bit-vec features enable PostgreSQL at compile time
because SQLx provides those type integrations for PostgreSQL. Their afastorm SQLite model
conversions use text representations, so an application can still connect to SQLite with one of
these features enabled. Enabling both sqlite and postgres is supported.
Optional type features enable only the listed built-in afastorm model types; they do not enable every type supported by SQLx. See Models for accepted field types and unsupported custom-field cases.
Examples
Default SQLite application with migrations:
afastorm = { version = "0.0.1", features = ["migrate"] }
PostgreSQL application with derive support, migrations, UUID, and chrono types:
afastorm = { version = "0.0.1", default-features = false, features = [
"derive", "postgres", "migrate", "uuid", "chrono"
] }
Application using SQLite with Decimal and JSON:
afastorm = { version = "0.0.1", features = ["rust_decimal"] }
Here JSON is available without a feature; rust_decimal adds the optional decimal model type.