| 1 | // Annoying how deprecation warnings trigger in the same module as the deprecated item. |
| 2 | #![allow(deprecated)] |
| 3 | // Cargo features are broken in this file. |
| 4 | // `AnyKind` may return at some point but it won't be a simple enum. |
| 5 | #![allow(unexpected_cfgs)] |
| 6 | |
| 7 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 9 | |
| 10 | #[deprecated = "not used or returned by any API"] |
| 11 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 12 | pub enum AnyKindrust-analyzer cargo sqlx-core 0.8.3 any/kind/AnyKind# { |
| 13 | #[cfg(feature = "postgres")] |
| 14 | Postgres, |
| 15 | |
| 16 | #[cfg(feature = "mysql")] |
| 17 | MySql, |
| 18 | |
| 19 | #[cfg(feature = "_sqlite")] |
| 20 | Sqlite, |
| 21 | |
| 22 | #[cfg(feature = "mssql")] |
| 23 | Mssql, |
| 24 | } |
| 25 | |
| 26 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for AnyKindrust-analyzer cargo sqlx-core 0.8.3 any/kind/AnyKind# { |
| 27 | type Errrust-analyzer cargo sqlx-core 0.8.3 any/kind/impl#[AnyKind][FromStr]Err# = Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 28 | |
| 29 | fn from_strrust-analyzer cargo sqlx-core 0.8.3 any/kind/impl#[AnyKind][FromStr]from_str().(url: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-core 0.8.3 any/kind/impl#[AnyKind][FromStr], Selfrust-analyzer cargo sqlx-core 0.8.3 any/kind/impl#[AnyKind][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 30 | match url { |
| 31 | #[cfg(feature = "postgres")] |
| 32 | _ if urlrust-analyzer cargo url 2.5.8 crate/.starts_with("postgres:") || urlrust-analyzer cargo url 2.5.8 crate/.starts_with("postgresql:") => { |
| 33 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AnyKindrust-analyzer cargo sqlx-core 0.8.3 any/kind/AnyKind#::Postgres) |
| 34 | } |
| 35 | |
| 36 | #[cfg(not(feature = "postgres"))] |
| 37 | _ if url.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("postgres:") || url.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("postgresql:") => { |
| 38 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Configurationrust-analyzer cargo sqlx-core 0.8.3 error/Error#Configuration#("database URL has the scheme of a PostgreSQL database but the `postgres` feature is not enabled".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 39 | } |
| 40 | |
| 41 | #[cfg(feature = "mysql")] |
| 42 | _ if urlrust-analyzer cargo url 2.5.8 crate/.starts_with("mysql:") || urlrust-analyzer cargo url 2.5.8 crate/.starts_with("mariadb:") => { |
| 43 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AnyKindrust-analyzer cargo sqlx-core 0.8.3 any/kind/AnyKind#::MySql) |
| 44 | } |
| 45 | |
| 46 | #[cfg(not(feature = "mysql"))] |
| 47 | _ if url.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("mysql:") || url.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("mariadb:") => { |
| 48 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Configurationrust-analyzer cargo sqlx-core 0.8.3 error/Error#Configuration#("database URL has the scheme of a MySQL database but the `mysql` feature is not enabled".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 49 | } |
| 50 | |
| 51 | #[cfg(feature = "_sqlite")] |
| 52 | _ if urlrust-analyzer cargo url 2.5.8 crate/.starts_with("sqlite:") => { |
| 53 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AnyKindrust-analyzer cargo sqlx-core 0.8.3 any/kind/AnyKind#::Sqlite) |
| 54 | } |
| 55 | |
| 56 | #[cfg(not(feature = "_sqlite"))] |
| 57 | _ if url.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("sqlite:") => { |
| 58 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Configurationrust-analyzer cargo sqlx-core 0.8.3 error/Error#Configuration#("database URL has the scheme of a SQLite database but the `sqlite` feature is not enabled".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 59 | } |
| 60 | |
| 61 | #[cfg(feature = "mssql")] |
| 62 | _ if urlrust-analyzer cargo url 2.5.8 crate/.starts_with("mssql:") || urlrust-analyzer cargo url 2.5.8 crate/.starts_with("sqlserver:") => { |
| 63 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AnyKindrust-analyzer cargo sqlx-core 0.8.3 any/kind/AnyKind#::Mssql) |
| 64 | } |
| 65 | |
| 66 | #[cfg(not(feature = "mssql"))] |
| 67 | _ if url.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("mssql:") || url.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("sqlserver:") => { |
| 68 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Configurationrust-analyzer cargo sqlx-core 0.8.3 error/Error#Configuration#("database URL has the scheme of a MSSQL database but the `mssql` feature is not enabled".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 69 | } |
| 70 | |
| 71 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Configurationrust-analyzer cargo sqlx-core 0.8.3 error/Error#Configuration#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("unrecognized database url: {url:?}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 72 | } |
| 73 | } |
| 74 | } |