Process

Struct Process 

Source
pub struct Process { /* private fields */ }

Implementations§

Source§

impl Process

Source

pub fn new() -> Self

Source

pub fn with_executable(self, executable: impl ToString) -> Self

Sets the executable to run.

Source

pub fn with_args(self, args: impl IntoIterator<Item = impl ToString>) -> Self

Sets the arguments to pass to the executable.

Source

pub fn with_cancel_timeout(self, t: impl Into<Option<Duration>>) -> Self

Sets the cancellation timeout before forcing the process to exit.

Source

pub fn with_env( self, env: impl IntoIterator<Item = (impl ToString, impl ToString)>, ) -> Self

Sets the environment variables to pass to the executable.

Source

pub fn with_on_stdout<F, A>(self, on_stdout: F) -> Self
where F: Fn(ProcessManager, ProcessKey, String) -> A + Unpin + Send + Sync + 'static, A: Future<Output = ()> + Send + 'static,

Sets the callback to run when the process writes to stdout.

Source

pub fn with_on_stderr<F, A>(self, on_stderr: F) -> Self
where F: Fn(ProcessManager, ProcessKey, String) -> A + Unpin + Send + Sync + 'static, A: Future<Output = ()> + Send + 'static,

Sets the callback to run when the process writes to stderr.

Source

pub fn with_fds<F>(self, fds: F) -> Self
where F: FnOnce() -> Vec<OwnedFd> + Send + Sync + 'static,

Shares Fds with the child process Closure produces a vector of Fd to share with the child process

Source

pub fn with_on_start<F, A>(self, on_start: F) -> Self
where F: Fn(ProcessManager, ProcessKey, bool) -> A + Unpin + Send + Sync + 'static, A: Future<Output = ()> + Send + 'static,

This is called when the process is started.

It passes a single argument: a bool indicating whether the process was restarted or if it was started for the first time.

Source

pub fn with_on_exit<F, A>(self, on_exit: F) -> Self
where F: Fn(ProcessManager, ProcessKey, Option<i32>, bool) -> A + Unpin + Send + Sync + 'static, A: Future<Output = ()> + Send + 'static,

Sets the callback to run when the process exits. This is called after the process exits, or before it restarts.

It passes two arguments: an optional exit code, and a bool indicating whether the process is going to be restarted or not.

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, 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V