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
impl PgEmbed
Sourcepub async fn new(
pg_settings: PgSettings,
fetch_settings: PgFetchSettings,
) -> PgResult<Self>
pub async fn new( pg_settings: PgSettings, fetch_settings: PgFetchSettings, ) -> PgResult<Self>
Create a new PgEmbed instance
Sourcepub async fn setup(&mut self) -> PgResult<()>
pub async fn setup(&mut self) -> PgResult<()>
Setup postgresql for execution
Download, unpack, create password file and database
Sourcepub async fn init_db(&mut self) -> PgResult<()>
pub async fn init_db(&mut self) -> PgResult<()>
Initialize postgresql database
Returns Ok(())
on success, otherwise returns an error.
Sourcepub async fn start_db(&mut self) -> PgResult<()>
pub async fn start_db(&mut self) -> PgResult<()>
Start postgresql database
Returns Ok(())
on success, otherwise returns an error.
Sourcepub async fn stop_db(&mut self) -> PgResult<()>
pub async fn stop_db(&mut self) -> PgResult<()>
Stop postgresql database
Returns Ok(())
on success, otherwise returns an error.
Sourcepub fn stop_db_sync(&mut self) -> PgResult<()>
pub fn stop_db_sync(&mut self) -> PgResult<()>
Stop postgresql database synchronous
Returns Ok(())
on success, otherwise returns an error.
Sourcepub fn handle_process_io_sync(&self, process: Child) -> PgResult<()>
pub fn handle_process_io_sync(&self, process: Child) -> PgResult<()>
Handle process logging synchronous
Sourcepub async fn create_database(&self, db_name: &str) -> PgResult<()>
pub async fn create_database(&self, db_name: &str) -> PgResult<()>
Create a database
Sourcepub async fn drop_database(&self, db_name: &str) -> PgResult<()>
pub async fn drop_database(&self, db_name: &str) -> PgResult<()>
Drop a database
Sourcepub async fn database_exists(&self, db_name: &str) -> PgResult<bool>
pub async fn database_exists(&self, db_name: &str) -> PgResult<bool>
Check database existence
Sourcepub fn full_db_uri(&self, db_name: &str) -> String
pub fn full_db_uri(&self, db_name: &str) -> String
The full database uri
(postgres://{username}:{password}@localhost:{port}/{db_name})
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PgEmbed
impl !RefUnwindSafe for PgEmbed
impl Send for PgEmbed
impl Sync for PgEmbed
impl Unpin for PgEmbed
impl !UnwindSafe for PgEmbed
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