1pub mod core;
7pub mod postgres;
8
9pub use core::*;
11pub use postgres::PostgresBackend;
12
13#[derive(Debug, Clone, PartialEq, Eq, Hash)]
15pub enum DatabaseBackendType {
16 PostgreSQL,
17 MySQL,
18 SQLite,
19}
20
21impl std::fmt::Display for DatabaseBackendType {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 DatabaseBackendType::PostgreSQL => write!(f, "postgresql"),
25 DatabaseBackendType::MySQL => write!(f, "mysql"),
26 DatabaseBackendType::SQLite => write!(f, "sqlite"),
27 }
28 }
29}
30
31impl std::str::FromStr for DatabaseBackendType {
32 type Err = String;
33
34 fn from_str(s: &str) -> Result<Self, Self::Err> {
35 match s.to_lowercase().as_str() {
36 "postgresql" | "postgres" => Ok(DatabaseBackendType::PostgreSQL),
37 "mysql" => Ok(DatabaseBackendType::MySQL),
38 "sqlite" => Ok(DatabaseBackendType::SQLite),
39 _ => Err(format!("Unsupported database backend: {}", s)),
40 }
41 }
42}