Files
tessera/crates/tessera-providers/src/lib.rs
2026-11-14 19:19:21 +07:00

45 lines
1.1 KiB
Rust

mod filesystem;
mod mysql;
mod mysql_restore;
mod postgres;
mod postgres_restore;
mod ssh;
pub use filesystem::*;
pub use mysql::MysqlSource;
pub use mysql_restore::MysqlRestore;
pub use postgres::*;
pub use postgres_restore::{PostgresReset, PostgresRestore};
pub use ssh::SshEndpoint;
use anyhow::Result;
use async_trait::async_trait;
use serde_json::Value;
use tessera_core::config::ProviderKind;
#[async_trait]
pub trait BackupProvider: Send + Sync {
fn kind(&self) -> ProviderKind;
async fn capture(&self) -> Result<CaptureResult>;
}
#[derive(Debug, Clone)]
pub struct CaptureResult {
pub payload: Vec<u8>,
pub labels: Vec<String>,
pub restore_hints: Value,
}
pub fn provider_from_config(
kind: &ProviderKind,
config: &Value,
) -> Result<Box<dyn BackupProvider>> {
match kind {
ProviderKind::Filesystem => Ok(Box::new(FilesystemProvider::from_config(config)?)),
ProviderKind::Postgres => Ok(Box::new(PostgresProvider::from_config(config)?)),
ProviderKind::Command => {
anyhow::bail!("command provider is outside this release; use filesystem or postgres")
}
}
}