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

The type to spawn commands.

Implementations

This is supported on crate feature command only.

Creates a new Command for launching the given program.

This is supported on crate feature command 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).

This is supported on crate feature command only.

Appends arguments to the command.

This is supported on crate feature command only.

Clears the entire environment map for the child process.

This is supported on crate feature command only.

Adds or updates multiple environment variable mappings.

This is supported on crate feature command only.

Sets the working directory for the child process.

This is supported on crate feature command 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;
      }
    }
  }
});
This is supported on crate feature command 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());
This is supported on crate feature command 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.

Should always be Self

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.