Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

FeatureDefaultEnablesNotes
deriveYes#[derive(Model)] via afastorm-deriveTurn off if implementing Model manually.
sqliteYesNative SQLx SQLite driverUsed by Orm::connect for sqlite: URLs.
postgresNoNative SQLx PostgreSQL driverUsed by Orm::connect for postgres:// and postgresql:// URLs.
migrateNoMigration API and afastorm CLIThe CLI binary is unavailable without this feature.
uuidNouuid::Uuid model/query supportEnable alongside the selected driver.
chronoNochrono date/time model/query typesProvides NaiveDate, NaiveTime, NaiveDateTime, and supported DateTime variants.
timeNotime crate date/time model/query typesProvides Date, Time, PrimitiveDateTime, and OffsetDateTime.
rust_decimalNorust_decimal::DecimalSQLite stores the decimal text representation; PostgreSQL uses NUMERIC.
bigdecimalNobigdecimal::BigDecimalSQLite stores the decimal text representation; PostgreSQL uses NUMERIC.
ipnetworkNostd::net::IpAddr and ipnetwork::IpNetworkAlso enables the postgres driver feature.
ipnetNostd::net::IpAddr and ipnet::IpNetAlso enables the postgres driver feature.
mac_addressNomac_address::MacAddressAlso enables the postgres driver feature.
bit-vecNobit_vec::BitVecAlso 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.