Module sync

Source
Expand description

Methods to execute a process “synchronously”, i.e. waiting until it has exited.

 use std::path::PathBuf;
 use super_process::{fs, exe, sync::SyncInvocable};

 let command = exe::Command {
   exe: exe::Exe(fs::File(PathBuf::from("echo"))),
   argv: ["hey"].as_ref().into(),
   ..Default::default()
 };

 // Spawn the child process and wait for it to end.
 let output = command.clone().invoke().await.expect("sync subprocess failed");
 // Parse stdout into utf8...
 let hey = output.decode(command).expect("utf8 decoding failed").stdout
   // ...and strip the trailing newline.
   .strip_suffix("\n")
   .expect("trailing newline not found");
 assert_eq!(hey, "hey");

Structs§

DecodedOutput
The slurped streams for a synchronously-invoked process, after UTF-8 decoding.
RawOutput
The slurped streams for a synchronously-invoked process, as raw bytes.

Traits§

SyncInvocable
Trait that defines “synchronously” invokable processes.