keepsake_sqlx/repository/
backend.rs1use std::fmt::Debug;
2use std::marker::PhantomData;
3
4pub trait KeepsakeSqlxBackend: Debug + Clone + Copy + Send + Sync + 'static {
6 type Database: sqlx::Database;
8
9 const NAME: &'static str;
11}
12
13#[cfg(feature = "postgres")]
15#[derive(Debug, Clone, Copy)]
16pub struct PostgresBackend;
17
18#[cfg(feature = "postgres")]
19impl KeepsakeSqlxBackend for PostgresBackend {
20 type Database = sqlx::Postgres;
21
22 const NAME: &'static str = "postgres";
23}
24
25#[cfg(feature = "sqlite")]
27#[derive(Debug, Clone, Copy)]
28pub struct SqliteBackend;
29
30#[cfg(feature = "sqlite")]
31impl KeepsakeSqlxBackend for SqliteBackend {
32 type Database = sqlx::Sqlite;
33
34 const NAME: &'static str = "sqlite";
35}
36
37#[cfg(feature = "mysql")]
39#[derive(Debug, Clone, Copy)]
40pub struct MySqlBackend;
41
42#[cfg(feature = "mysql")]
43impl KeepsakeSqlxBackend for MySqlBackend {
44 type Database = sqlx::MySql;
45
46 const NAME: &'static str = "mysql";
47}
48
49#[derive(Debug, Clone, Copy)]
50pub(super) struct BackendMarker<B>(PhantomData<B>);
51
52impl<B> BackendMarker<B> {
53 pub(super) const fn new() -> Self {
54 Self(PhantomData)
55 }
56}
57
58impl<B> Default for BackendMarker<B> {
59 fn default() -> Self {
60 Self::new()
61 }
62}