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

The type to spawn commands.

Implementations

Available on crate feature process-command-api only.

Creates a new Command for launching the given program.

Available on crate feature process-command-api only.

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).

Available on crate feature process-command-api only.

Appends arguments to the command.

Available on crate feature process-command-api only.

Clears the entire environment map for the child process.

Available on crate feature process-command-api only.

Adds or updates multiple environment variable mappings.

Available on crate feature process-command-api only.

Sets the working directory for the child process.

Available on crate feature process-command-api only.

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;
      }
    }
  }
});
Available on crate feature process-command-api only.

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());
Available on crate feature process-command-api only.

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

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.