Struct postgresfixture::cluster::Cluster
source · [−]pub struct Cluster { /* private fields */ }
Expand description
Representation of a PostgreSQL cluster.
The cluster may not yet exist on disk. It may exist but be stopped, or it
may be running. The methods here can be used to create, start, introspect,
stop, and destroy the cluster. There’s no protection against concurrent
changes to the cluster made by other processes, but the functions in the
coordinate
module may help.
Implementations
sourceimpl Cluster
impl Cluster
pub fn new<P: AsRef<Path>>(datadir: P, runtime: Runtime) -> Self
sourcepub fn exists(&self) -> bool
pub fn exists(&self) -> bool
A fairly simplistic check: does the data directory exist and does it
contain a file named PG_VERSION
?
sourcepub fn running(&self) -> Result<bool, ClusterError>
pub fn running(&self) -> Result<bool, ClusterError>
Check if this cluster is running.
Tries to distinguish carefully between “definitely running”, “definitely
not running”, and “don’t know”. The latter results in ClusterError
.
sourcepub fn pidfile(&self) -> PathBuf
pub fn pidfile(&self) -> PathBuf
Return the path to the PID file used in this cluster.
The PID file does not necessarily exist.
sourcepub fn logfile(&self) -> PathBuf
pub fn logfile(&self) -> PathBuf
Return the path to the log file used in this cluster.
The log file does not necessarily exist.
sourcepub fn create(&self) -> Result<bool, ClusterError>
pub fn create(&self) -> Result<bool, ClusterError>
Create the cluster if it does not already exist.
pub fn start(&self) -> Result<bool, ClusterError>
pub fn connect(&self, database: &str) -> Result<Client, ClusterError>
pub fn shell(&self, database: &str) -> Result<ExitStatus, ClusterError>
pub fn exec<T: AsRef<OsStr>>(
&self,
database: &str,
command: T,
args: &[T]
) -> Result<ExitStatus, ClusterError>
pub fn databases(&self) -> Result<Vec<String>, ClusterError>
sourcepub fn createdb(&self, database: &str) -> Result<bool, ClusterError>
pub fn createdb(&self, database: &str) -> Result<bool, ClusterError>
Create the named database.
pub fn stop(&self) -> Result<bool, ClusterError>
pub fn destroy(&self) -> Result<bool, ClusterError>
Auto Trait Implementations
impl RefUnwindSafe for Cluster
impl Send for Cluster
impl Sync for Cluster
impl Unpin for Cluster
impl UnwindSafe for Cluster
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more