elif_orm/backends/
mod.rs

1//! Database Backend Abstractions
2//!
3//! This module provides database backend abstractions to support multiple database types
4//! (PostgreSQL, MySQL, SQLite, etc.) through common traits and interfaces.
5
6pub mod core;
7pub mod postgres;
8
9// Re-export core traits and types
10pub use core::*;
11pub use postgres::PostgresBackend;
12
13/// Database backend type enumeration
14#[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}