Struct PgEmbed

Source
pub struct PgEmbed {
    pub pg_settings: PgSettings,
    pub fetch_settings: PgFetchSettings,
    pub db_uri: String,
    pub server_status: Arc<Mutex<PgServerStatus>>,
    pub shutting_down: bool,
    pub pg_access: PgAccess,
}
Expand description

Embedded postgresql database

If the PgEmbed instance is dropped / goes out of scope and postgresql is still running, the postgresql process will be killed and depending on the PgSettings::persistent setting, file and directories will be cleaned up.

Fields§

§pg_settings: PgSettings

Postgresql settings

§fetch_settings: PgFetchSettings

Download settings

§db_uri: String

Database uri postgres://{username}:{password}@localhost:{port}

§server_status: Arc<Mutex<PgServerStatus>>

Postgres server status

§shutting_down: bool§pg_access: PgAccess

Postgres files access

Implementations§

Source§

impl PgEmbed

Source

pub async fn new( pg_settings: PgSettings, fetch_settings: PgFetchSettings, ) -> PgResult<Self>

Create a new PgEmbed instance

Source

pub async fn setup(&mut self) -> PgResult<()>

Setup postgresql for execution

Download, unpack, create password file and database

Source

pub async fn init_db(&mut self) -> PgResult<()>

Initialize postgresql database

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

Source

pub async fn start_db(&mut self) -> PgResult<()>

Start postgresql database

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

Source

pub async fn stop_db(&mut self) -> PgResult<()>

Stop postgresql database

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

Source

pub fn stop_db_sync(&mut self) -> PgResult<()>

Stop postgresql database synchronous

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

Source

pub fn handle_process_io_sync(&self, process: Child) -> PgResult<()>

Handle process logging synchronous

Source

pub async fn create_database(&self, db_name: &str) -> PgResult<()>

Create a database

Source

pub async fn drop_database(&self, db_name: &str) -> PgResult<()>

Drop a database

Source

pub async fn database_exists(&self, db_name: &str) -> PgResult<bool>

Check database existence

Source

pub fn full_db_uri(&self, db_name: &str) -> String

The full database uri

(postgres://{username}:{password}@localhost:{port}/{db_name})

Source

pub async fn migrate(&self, db_name: &str) -> PgResult<()>

Run migrations

Trait Implementations§

Source§

impl Drop for PgEmbed

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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,