Skip to main content

ProcessGuard

Struct ProcessGuard 

Source
pub struct ProcessGuard {
    pub stdout_reader: Option<Lines<BufReader<ChildStdout>>>,
    pub stderr_reader: Option<Lines<BufReader<ChildStderr>>>,
    pub port: u32,
    pub db_name: String,
    pub user_name: String,
    /* private fields */
}
Expand description

ProcessGuard represents a postgresql process that is running in the background. once the guard is dropped the process will be killed.

Fields§

§stdout_reader: Option<Lines<BufReader<ChildStdout>>>

Allows users to read stdout by line for debugging.

§stderr_reader: Option<Lines<BufReader<ChildStderr>>>

Allows users to read stderr by line for debugging.

§port: u32

Parameters for connecting to the temporary postgresql instance.

A user shouldn’t need to use these and should call connection_string instead.

Port number that Postgresql is serving on

§db_name: String

Database name to connect to.

§user_name: String

Username to connect as.

Implementations§

Source§

impl ProcessGuard

Source

pub fn connection_string(&self) -> String

Get a Postgresql format connection String for the process guard.

§Panics

Panics if a string file path cannot be obtained from the socket directory.

Source

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

Get a Postgresql format connection string for a database on this running instance.

§Panics

Panics if a string file path cannot be obtained from the socket directory.

Source

pub fn clone_database(&self, db_name: &str) -> TmpPostgrustResult<String>

Clone the current database in this running instance.

The returned connection string points at the newly-created database.

§Errors

Returns an error if createdb fails to clone the current database.

Trait Implementations§

Source§

impl Drop for ProcessGuard

Signal that the process needs to end.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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, 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<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