use crate::{PgDbInfo, Result, Rudof, api::pg_db::PgDbOperations, formats::BackendSpec};
use std::path::Path;
pub struct ConnectPgDbBuilder<'a> {
rudof: &'a mut Rudof,
path: Option<&'a Path>,
in_memory: bool,
read_only: bool,
engine: Option<&'a BackendSpec>,
}
impl<'a> ConnectPgDbBuilder<'a> {
pub(crate) fn new(rudof: &'a mut Rudof, path: Option<&'a Path>) -> Self {
Self {
rudof,
path,
in_memory: false,
read_only: false,
engine: None,
}
}
pub fn with_in_memory(mut self, in_memory: bool) -> Self {
self.in_memory = in_memory;
self
}
pub fn with_read_only(mut self, read_only: bool) -> Self {
self.read_only = read_only;
self
}
pub fn with_engine(mut self, engine: &'a BackendSpec) -> Self {
self.engine = Some(engine);
self
}
pub fn execute(self) -> Result<PgDbInfo> {
<Rudof as PgDbOperations>::connect_pg_db(self.rudof, self.path, self.in_memory, self.read_only, self.engine)
}
}