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§

source§

impl Cluster

source

pub fn new<P: AsRef<Path>, S: RuntimeStrategy>( datadir: P, strategy: S ) -> Result<Self, ClusterError>

Represent a cluster at the given path.

source

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.

source

pub fn pidfile(&self) -> PathBuf

Return the path to the PID file used in this cluster.

The PID file does not necessarily exist.

source

pub fn logfile(&self) -> PathBuf

Return the path to the log file used in this cluster.

The log file does not necessarily exist.

source

pub fn create(&self) -> Result<bool, ClusterError>

Create the cluster if it does not already exist.

source

pub fn start(&self) -> Result<bool, ClusterError>

source

pub fn connect(&self, database: &str) -> Result<Client, ClusterError>

source

pub fn shell(&self, database: &str) -> Result<ExitStatus, ClusterError>

source

pub fn exec<T: AsRef<OsStr>>( &self, database: &str, command: T, args: &[T] ) -> Result<ExitStatus, ClusterError>

source

pub fn databases(&self) -> Result<Vec<String>, ClusterError>

source

pub fn createdb(&self, database: &str) -> Result<bool, ClusterError>

Create the named database.

source

pub fn dropdb(&self, database: &str) -> Result<bool, ClusterError>

Drop the named database.

source

pub fn stop(&self) -> Result<bool, ClusterError>

source

pub fn destroy(&self) -> Result<bool, ClusterError>

Trait Implementations§

source§

impl AsRef<Path> for Cluster

source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
§

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

§

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