pub async fn init_default_non_sqlite(
creds: Option<Credentials>,
) -> Result<Box<dyn Database>, InitDbError>Expand description
Initializes a non-SQLite database connection based on active feature flags.
This function is similar to init but specifically for non-SQLite backends
(e.g., PostgreSQL). It selects the appropriate database based on compile-time
features and returns a boxed trait object implementing the Database interface.
§Panics
- If invalid features are specified for the crate
§Errors
InitDbError::CredentialsRequiredwhen a credentials-based backend is active andcredsisNoneInitDbError::InitPostgreswhenpostgresbackend initialization fails (when enabled)InitDbError::InitDatabasewhen sqlx/rawPostgreSQLinitialization fails (when enabled)
§Examples
use switchy_database_connection::{init_default_non_sqlite, Credentials};
let creds = Credentials::from_url("postgres://user:pass@localhost:5432/moosicbox")
.expect("URL should parse");
let _db = init_default_non_sqlite(Some(creds)).await?;