LocalEnv

Struct LocalEnv 

Source
pub struct LocalEnv(/* private fields */);
Expand description

A local execution environment.

Implementations§

Source§

impl LocalEnv

Source

pub fn new<P: AsRef<Path>>(cwd: P) -> Self

Creates an execution environment with the given working directory.

Source

pub fn current_dir() -> Result<Self, Error>

Creates an execution environment with the current working directory.

Source

pub fn cwd(&self) -> &Path

The working directory of the environment.

Source

pub fn set_cwd<P: AsRef<Path>>(&mut self, cwd: P) -> &mut Self

Sets the working directory of the environment.

Source

pub fn with_cwd<P: AsRef<Path>>(self, cwd: P) -> Self

Sets the working directory of the environment.

Source

pub fn vars(&self) -> &Vars

The environment variables of the environment.

Source

pub fn set_vars(&mut self, vars: Vars) -> &mut Self

Sets the environment variables of the environment.

Source

pub fn with_vars(self, vars: Vars) -> Self

Sets the environment variables of the environment.

Source

pub fn set_var<N: AsRef<OsStr>, V: AsRef<OsStr>>( &mut self, name: N, value: V, ) -> &mut Self

Sets an environment variable.

Source

pub fn with_var<N: AsRef<OsStr>, V: AsRef<OsStr>>( self, name: N, value: V, ) -> Self

Sets an environment variable.

Source

pub fn default_stdin(&self) -> &In

The default stdin input to provide to commands.

Source

pub fn with_default_stdin(self, stdin: In) -> Self

Sets the default stdin input to provide to commands.

Source

pub fn default_stdout(&self) -> &Out

Indicates what to do with the stdout output of commands by default.

Source

pub fn with_default_stdout(self, stdout: Out) -> Self

Sets what to do with the stdout output of commands by default.

Source

pub fn default_stderr(&self) -> &Out

Indicates what to do with the stderr output of commands by default.

Source

pub fn with_default_stderr(self, stderr: Out) -> Self

Source

pub fn with_echo(self) -> Self

Enables the echoing of commands.

Source

pub fn without_echo(self) -> Self

Disables the echoing of commands.

Source

pub fn change_dir<P: AsRef<Path>>( &mut self, path: P, ) -> Result<&mut Self, Error>

Changes the working directory of the environment.

Source

pub fn resolve_path<P: AsRef<Path>>(&self, path: P) -> PathBuf

Resolves a path relative to the working directory of the environment.

Trait Implementations§

Source§

impl Clone for LocalEnv

Source§

fn clone(&self) -> LocalEnv

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LocalEnv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Run<OsString> for LocalEnv

Source§

fn run(&self, cmd: Cmd<OsString>) -> Result<RunOutput, RunError<OsString>>

Runs a command returning its output.
Source§

fn read_str(&self, cmd: Cmd<S>) -> Result<String, RunError<S>>

Runs a command returning its stdout output as a string.
Source§

fn read_bytes(&self, cmd: Cmd<S>) -> Result<Vec<u8>, RunError<S>>

Runs a command returning its stderr output as a string.
Source§

impl RunAsync<OsString> for LocalEnv

Available on crate feature tokio only.
Source§

async fn run(&self, cmd: Cmd) -> RunResult<RunOutput, OsString>

Available on crate feature async only.
Source§

fn read_str( &self, cmd: Cmd<S>, ) -> impl Send + Future<Output = RunResult<String, S>>

Available on crate feature async only.
Source§

fn read_bytes( &self, cmd: Cmd<S>, ) -> impl Send + Future<Output = RunResult<Vec<u8>, S>>

Available on crate feature async only.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.