pub struct SpawnOptions { /* private fields */ }Expand description
Configuration options for spawning a new process.
Implementations§
Source§impl SpawnOptions
impl SpawnOptions
Sourcepub fn builder(argv: Vec<String>, backend: SpawnBackend) -> SpawnOptionsBuilder
pub fn builder(argv: Vec<String>, backend: SpawnBackend) -> SpawnOptionsBuilder
Create a new builder for process spawning.
Examples found in repository?
examples/spawn_ls.rs (lines 6-9)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 println!("Spawning '/bin/ls -l'...");
5
6 let output = SpawnOptions::builder(
7 vec!["/bin/ls".to_string(), "-l".to_string()],
8 SpawnBackend::PosixSpawn,
9 )
10 .capture_stdout()
11 .timeout_ms(5000)
12 .build()?
13 .run()?;
14
15 println!("Exit status: {:?}", output.status);
16 println!("Output length: {} bytes", output.stdout.len());
17 println!("--- STDOUT ---");
18 println!("{}", String::from_utf8_lossy(&output.stdout));
19 println!("--------------");
20
21 Ok(())
22}Sourcepub fn run(self) -> Result<Output, CoreError>
pub fn run(self) -> Result<Output, CoreError>
Execute the process according to the options and block until completion.
Examples found in repository?
examples/spawn_ls.rs (line 13)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 println!("Spawning '/bin/ls -l'...");
5
6 let output = SpawnOptions::builder(
7 vec!["/bin/ls".to_string(), "-l".to_string()],
8 SpawnBackend::PosixSpawn,
9 )
10 .capture_stdout()
11 .timeout_ms(5000)
12 .build()?
13 .run()?;
14
15 println!("Exit status: {:?}", output.status);
16 println!("Output length: {} bytes", output.stdout.len());
17 println!("--- STDOUT ---");
18 println!("{}", String::from_utf8_lossy(&output.stdout));
19 println!("--------------");
20
21 Ok(())
22}Trait Implementations§
Source§impl Clone for SpawnOptions
impl Clone for SpawnOptions
Source§fn clone(&self) -> SpawnOptions
fn clone(&self) -> SpawnOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SpawnOptions
impl RefUnwindSafe for SpawnOptions
impl Send for SpawnOptions
impl Sync for SpawnOptions
impl Unpin for SpawnOptions
impl UnsafeUnpin for SpawnOptions
impl UnwindSafe for SpawnOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more