pub struct Command { /* private fields */ }
Available on crate feature process-command-api only.
Expand description

The type to spawn commands.

Implementations

Creates a new Command for launching the given program.

Creates a new Command for launching the given sidecar program.

A sidecar program is a embedded external binary in order to make your application work or to prevent users having to install additional dependencies (e.g. Node.js, Python, etc).

Appends arguments to the command.

Clears the entire environment map for the child process.

Adds or updates multiple environment variable mappings.

Sets the working directory for the child process.

Sets the character encoding for stdout/stderr.

Spawns the command.

Examples
use tauri::api::process::{Command, CommandEvent};
tauri::async_runtime::spawn(async move {
  let (mut rx, mut child) = Command::new("cargo")
    .args(["tauri", "dev"])
    .spawn()
    .expect("Failed to spawn cargo");

  let mut i = 0;
  while let Some(event) = rx.recv().await {
    if let CommandEvent::Stdout(line) = event {
      println!("got: {}", line);
      i += 1;
      if i == 4 {
        child.write("message from Rust\n".as_bytes()).unwrap();
        i = 0;
      }
    }
  }
});

Executes a command as a child process, waiting for it to finish and collecting its exit status. Stdin, stdout and stderr are ignored.

Examples
use tauri::api::process::Command;
let status = Command::new("which").args(["ls"]).status().unwrap();
println!("`which` finished with status: {:?}", status.code());

Executes the command as a child process, waiting for it to finish and collecting all of its output. Stdin is ignored.

Examples
use tauri::api::process::Command;
let output = Command::new("echo").args(["TAURI"]).output().unwrap();
assert!(output.status.success());
assert_eq!(output.stdout, "TAURI");

Trait Implementations

Formats the value using the given formatter. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.