Struct temp_postgres::TempPostgres
source · pub struct TempPostgres { /* private fields */ }
Expand description
A temporary postgres instance.
All state of the postgres instance is stored in a temporary directory. Unless disabled, the temporary directory is deleted when this object is dropped.
Implementations§
source§impl TempPostgres
impl TempPostgres
sourcepub async fn new() -> Result<Self, Error>
pub async fn new() -> Result<Self, Error>
Spawn a new postgres instance with a temporary state directory.
sourcepub fn builder() -> TempPostgresBuilder
pub fn builder() -> TempPostgresBuilder
Create a builder to customize your TempPostgres
.
After configuring the desirec options, run TempPostgresBuilder::spawn()
.
sourcepub fn process_id(&self) -> u32
pub fn process_id(&self) -> u32
Get the PID of the postgres server process.
sourcepub async fn client(&self) -> Result<Client, Error>
pub async fn client(&self) -> Result<Client, Error>
Connect an asycnchronous client to the postgres instance.
sourcepub fn set_clean_on_drop(&mut self, clean_on_drop: bool)
pub fn set_clean_on_drop(&mut self, clean_on_drop: bool)
Enable or disable clean-up of the temporary directory when this object is dropped.
sourcepub async fn kill_and_clean(self) -> Result<(), Error>
pub async fn kill_and_clean(self) -> Result<(), Error>
Kill the server and remove the temporary state directory on the filesystem.
Note that the server will also be killed when this object is dropped,
and unless disabled, the temporary state directory will be removed by the Drop
implementation too.
This function ignores the value of clean_on_drop
.
It also allows for better error handling compared to just dropping the object.
sourcepub async fn kill_no_clean(self) -> Result<(), Error>
pub async fn kill_no_clean(self) -> Result<(), Error>
Kill the server, but leave the temporary state directory on the filesystem.
Note that the server will also be killed when this object is dropped.
This function ignores the value of clean_on_drop
.
It also allows for better error handling compared to just dropping the object.