Struct PgAccess

Source
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: PathBuf

Cache directory path

§database_dir: PathBuf

Database directory path

§pg_ctl_exe: PathBuf

Postgresql pg_ctl executable path

§init_db_exe: PathBuf

Postgresql initdb executable path

§pw_file_path: PathBuf

Password file path

§zip_file_path: PathBuf

Postgresql binaries zip file path

Implementations§

Source§

impl PgAccess

Source

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

Source

pub async fn pg_executables_cached(&self) -> PgResult<bool>

Check if postgresql executables are already cached

Source

pub async fn db_files_exist(&self) -> PgResult<bool>

Check if database files exist

Source

pub async fn pg_version_file_exists(db_dir: &PathBuf) -> PgResult<bool>

Check if database version file exists

Source

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

Source

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

Source

pub async fn acquisition_status(&self) -> PgAcquisitionStatus

Check postgresql acquisition status

Source

pub async fn acquisition_needed(&self) -> PgResult<bool>

Determine if postgresql binaries acquisition is needed

Source

pub async fn write_pg_zip(&self, bytes: &[u8]) -> PgResult<()>

Write pg binaries zip to postgresql cache directory

Source

pub fn clean(&self) -> PgResult<()>

Clean up created files and directories.

Remove created directories containing the database and the password file.

Source

pub async fn purge() -> PgResult<()>

Purge postgresql executables

Remove all cached postgresql executables

Source

pub async fn clean_up(database_dir: PathBuf, pw_file: PathBuf) -> PgResult<()>

Clean up database directory and password file

Source

pub async fn create_password_file(&self, password: &[u8]) -> PgResult<()>

Create a database password file

Returns Ok(()) on success, otherwise returns an error.

Source

pub fn stop_db_command_sync(&self, database_dir: &PathBuf) -> PgCommandSync

Create synchronous pg_ctl stop command

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,