mod lance;
mod postgres;
mod redb;
#[cfg(feature = "sqlite")]
mod sqlite;
use serde::{Deserialize, Serialize};
use crate::StateStoreError;
pub use lance::{LanceStateStoreConfig, LanceStateStoreLocation};
pub use postgres::{PostgresStateStoreConfig, PostgresStateStoreTlsMode};
pub use redb::{RedbStateStoreConfig, RedbStateStoreLocation};
#[cfg(feature = "sqlite")]
pub use sqlite::{SqliteStateStoreConfig, SqliteStateStoreLocation};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum StateStoreConfig {
Lance(LanceStateStoreConfig),
Redb(RedbStateStoreConfig),
Postgres(PostgresStateStoreConfig),
#[cfg(feature = "sqlite")]
Sqlite(SqliteStateStoreConfig),
}
impl StateStoreConfig {
#[must_use]
pub fn lance(config: LanceStateStoreConfig) -> Self {
Self::Lance(config)
}
#[must_use]
pub fn redb(config: RedbStateStoreConfig) -> Self {
Self::Redb(config)
}
#[must_use]
pub fn postgres(config: PostgresStateStoreConfig) -> Self {
Self::Postgres(config)
}
#[cfg(feature = "sqlite")]
#[must_use]
pub fn sqlite(config: SqliteStateStoreConfig) -> Self {
Self::Sqlite(config)
}
pub fn validate(&self) -> Result<(), StateStoreError> {
match self {
Self::Lance(config) => config.validate(),
Self::Redb(config) => config.validate(),
Self::Postgres(config) => config.validate(),
#[cfg(feature = "sqlite")]
Self::Sqlite(config) => config.validate(),
}
}
}
impl From<LanceStateStoreConfig> for StateStoreConfig {
fn from(config: LanceStateStoreConfig) -> Self {
Self::Lance(config)
}
}
impl From<RedbStateStoreConfig> for StateStoreConfig {
fn from(config: RedbStateStoreConfig) -> Self {
Self::Redb(config)
}
}
impl From<PostgresStateStoreConfig> for StateStoreConfig {
fn from(config: PostgresStateStoreConfig) -> Self {
Self::Postgres(config)
}
}
#[cfg(feature = "sqlite")]
impl From<SqliteStateStoreConfig> for StateStoreConfig {
fn from(config: SqliteStateStoreConfig) -> Self {
Self::Sqlite(config)
}
}