use std::path::PathBuf;
use std::sync::Arc;
use async_trait::async_trait;
use crate::platform::error::PlatformError;
use crate::platform::model::{
DescribeProjectDbConnectionRequest, ProjectDbConnection, ProjectDbConnectionDescribeResult,
ProjectDbConnectionQueryResult, QueryProjectDbConnectionRequest,
};
use crate::platform::services::CredentialService;
#[derive(Clone)]
pub struct DbDriverContext {
pub owner: String,
pub project: String,
pub data_root: PathBuf,
pub connection: ProjectDbConnection,
pub credentials: Arc<CredentialService>,
}
#[async_trait]
pub trait DbDriver: Send + Sync {
fn kind(&self) -> &'static str;
async fn describe(
&self,
ctx: &DbDriverContext,
req: &DescribeProjectDbConnectionRequest,
) -> Result<ProjectDbConnectionDescribeResult, PlatformError>;
async fn query(
&self,
ctx: &DbDriverContext,
req: &QueryProjectDbConnectionRequest,
) -> Result<ProjectDbConnectionQueryResult, PlatformError>;
}