pub struct PgAccess {
pub cache_dir: PathBuf,
pub database_dir: PathBuf,
pub pg_ctl_exe: PathBuf,
pub init_db_exe: PathBuf,
pub pw_file_path: PathBuf,
pub zip_file_path: PathBuf,
/* private fields */
}Expand description
Access to pg_ctl, initdb, database directory and cache directory
Fields§
§cache_dir: PathBufCache directory path
database_dir: PathBufDatabase directory path
pg_ctl_exe: PathBufPostgresql pg_ctl executable path
init_db_exe: PathBufPostgresql initdb executable path
pw_file_path: PathBufPassword file path
zip_file_path: PathBufPostgresql binaries zip file path
Implementations§
Source§impl PgAccess
impl PgAccess
Sourcepub async fn new(
fetch_settings: &PgFetchSettings,
database_dir: &PathBuf,
) -> Result<Self, PgEmbedError>
pub async fn new( fetch_settings: &PgFetchSettings, database_dir: &PathBuf, ) -> Result<Self, PgEmbedError>
Create a new instance
Directory structure for cached postgresql binaries will be created
Sourcepub async fn pg_executables_cached(&self) -> PgResult<bool>
pub async fn pg_executables_cached(&self) -> PgResult<bool>
Check if postgresql executables are already cached
Sourcepub async fn db_files_exist(&self) -> PgResult<bool>
pub async fn db_files_exist(&self) -> PgResult<bool>
Check if database files exist
Sourcepub async fn pg_version_file_exists(db_dir: &PathBuf) -> PgResult<bool>
pub async fn pg_version_file_exists(db_dir: &PathBuf) -> PgResult<bool>
Check if database version file exists
Sourcepub async fn mark_acquisition_in_progress(&self) -> PgResult<()>
pub async fn mark_acquisition_in_progress(&self) -> PgResult<()>
Mark postgresql binaries acquisition in progress
Used while acquiring postgresql binaries, so that no two instances of PgEmbed try to acquire the same resources
Sourcepub async fn mark_acquisition_finished(&self) -> PgResult<()>
pub async fn mark_acquisition_finished(&self) -> PgResult<()>
Mark postgresql binaries acquisition finished
Used when acquiring postgresql has finished, so that other instances of PgEmbed don’t try to reacquire resources
Sourcepub async fn acquisition_status(&self) -> PgAcquisitionStatus
pub async fn acquisition_status(&self) -> PgAcquisitionStatus
Check postgresql acquisition status
Sourcepub async fn acquisition_needed(&self) -> PgResult<bool>
pub async fn acquisition_needed(&self) -> PgResult<bool>
Determine if postgresql binaries acquisition is needed
Sourcepub async fn write_pg_zip(&self, bytes: &[u8]) -> PgResult<()>
pub async fn write_pg_zip(&self, bytes: &[u8]) -> PgResult<()>
Write pg binaries zip to postgresql cache directory
Sourcepub fn clean(&self) -> PgResult<()>
pub fn clean(&self) -> PgResult<()>
Clean up created files and directories.
Remove created directories containing the database and the password file.
Sourcepub async fn purge() -> PgResult<()>
pub async fn purge() -> PgResult<()>
Purge postgresql executables
Remove all cached postgresql executables
Sourcepub async fn clean_up(database_dir: PathBuf, pw_file: PathBuf) -> PgResult<()>
pub async fn clean_up(database_dir: PathBuf, pw_file: PathBuf) -> PgResult<()>
Clean up database directory and password file
Sourcepub async fn create_password_file(&self, password: &[u8]) -> PgResult<()>
pub async fn create_password_file(&self, password: &[u8]) -> PgResult<()>
Create a database password file
Returns Ok(()) on success, otherwise returns an error.
Sourcepub fn stop_db_command_sync(&self, database_dir: &PathBuf) -> PgCommandSync
pub fn stop_db_command_sync(&self, database_dir: &PathBuf) -> PgCommandSync
Create synchronous pg_ctl stop command
Auto Trait Implementations§
impl Freeze for PgAccess
impl RefUnwindSafe for PgAccess
impl Send for PgAccess
impl Sync for PgAccess
impl Unpin for PgAccess
impl UnwindSafe for PgAccess
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more