pub mod config; pub mod postgresql; pub mod sqlite; use async_trait::async_trait; use shared::db_type::DBType; use std::error::Error; use std::sync::Arc; use url::Host; use testcontainers::{ContainerAsync, GenericImage}; use crate::{ WithContainer, WithoutContainer, containers::{DBConfigInfoType, UnStartedContainer}, }; #[derive(Clone)] pub struct PreExistingDBInfo { pub db_type: DBType, pub url: String, pub on_delete: Arc, } impl WithoutContainer for PreExistingDBInfo { fn on_delete(&self) { (self.on_delete)(); } } #[derive(Clone)] pub struct ContainerizedDBInfo { pub db_type: DBType, pub container: Arc>, pub container_name: String, pub database_name: String, pub host: Host, pub port: u16, pub url: String, pub user: String, pub password: String, } impl WithContainer for ContainerizedDBInfo { fn container(&self) -> &Arc> { &self.container } } #[async_trait] pub trait DBInfo { async fn new(config: Option) -> Self where Self: Sized; async fn get_db_container_config_info(&self) -> DBConfigInfoType; fn get_unstarted_container(&self) -> Result>; }