Struct Command

Source
pub struct Command { /* private fields */ }
Expand description

A command to be spawned.

Implementations§

Source§

impl Command

Source

pub fn new(prog: &str) -> Self

Creates a new command to be spawned.

prog should be the path to the program being spawned. If prog does not contain a /, then it will be searched in PATH similar to how a shell would do it.

The first argument passed to prog, argv[0], is prog itself.

Source

pub fn arg(&mut self, arg: &str) -> &mut Self

Adds an argument to be passed to the command.

Source

pub fn env(&mut self, key: &str, val: &str) -> &mut Self

Sets an environment variable for this command only.

Source

pub fn fd<F: Into<OwnedFd>>(&mut self, idx: i32, fd: F) -> &mut Self

Sets a file descriptor of the process.

By default, the process starts with exactly stdin, stdout, and stderr open and all pointing to /dev/null.

Source

pub fn stdin<F: Into<OwnedFd>>(&mut self, fd: F) -> &mut Self

Sets the stdin of the process.

This is equivalent to fd(0, fd).

Source

pub fn stdout<F: Into<OwnedFd>>(&mut self, fd: F) -> &mut Self

Sets the stdout of the process.

This is equivalent to fd(1, fd).

Source

pub fn stderr<F: Into<OwnedFd>>(&mut self, fd: F) -> &mut Self

Sets the stderr of the process.

This is equivalent to fd(2, fd).

Source

pub fn privileged(&mut self) -> &mut Self

Runs the application with access to privileged wayland protocols.

The default is false.

Source

pub fn spawn(&self)

Executes the command.

This consumes all attached file descriptors.

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.