#[cfg(feature = "postgres")]
pub(in crate::state::merkle::sql) mod postgres;
#[cfg(feature = "sqlite")]
mod sqlite;
use crate::error::InternalError;
#[cfg(feature = "state-merkle-sql-postgres-tests")]
pub use postgres::test::run_postgres_test;
#[cfg(all(feature = "postgres", feature = "state-merkle-sql-in-transaction"))]
pub use postgres::InTransactionPostgresBackend;
#[cfg(feature = "postgres")]
pub use postgres::{PostgresBackend, PostgresBackendBuilder, PostgresConnection};
#[cfg(all(feature = "sqlite", feature = "state-merkle-sql-in-transaction"))]
pub use sqlite::InTransactionSqliteBackend;
#[cfg(feature = "sqlite")]
pub use sqlite::{JournalMode, SqliteBackend, SqliteBackendBuilder, SqliteConnection, Synchronous};
pub trait Connection {
type ConnectionType: diesel::Connection;
fn as_inner(&self) -> &Self::ConnectionType;
}
#[cfg(feature = "state-merkle-sql-in-transaction")]
pub trait Backend {
type Connection: Connection;
fn connection(&self) -> Result<Self::Connection, InternalError>;
}
#[cfg(not(feature = "state-merkle-sql-in-transaction"))]
pub trait Backend {
type Connection: Connection;
fn connection(&self) -> Result<Self::Connection, InternalError>;
}
pub trait Execute: Backend {
fn execute<F, T>(&self, f: F) -> Result<T, InternalError>
where
F: Fn(&Self::Connection) -> Result<T, InternalError>;
}
pub trait WriteExclusiveExecute: Backend {
fn execute_write<F, T>(&self, f: F) -> Result<T, InternalError>
where
F: Fn(&Self::Connection) -> Result<T, InternalError>;
fn execute_read<F, T>(&self, f: F) -> Result<T, InternalError>
where
F: Fn(&Self::Connection) -> Result<T, InternalError>;
}