pub struct P4Command<'a> { /* private fields */ }Expand description
Builder-style interface for running a single p4 command.
Obtain one via P4Cli::command() and chain configuration calls
before calling run.
Implementations§
Source§impl<'a> P4Command<'a>
impl<'a> P4Command<'a>
Sourcepub fn args(&mut self, args: &[impl AsRef<OsStr>]) -> &mut Self
pub fn args(&mut self, args: &[impl AsRef<OsStr>]) -> &mut Self
Append all arguments from a slice.
Sourcepub fn timeout(&mut self, timeout: Duration) -> &mut Self
pub fn timeout(&mut self, timeout: Duration) -> &mut Self
Maximum wall-clock time the process is allowed to run. When exceeded the process is killed.
Note: Only the direct child process is terminated, not its descendants (no process-tree kill).
Sourcepub fn cwd(&mut self, path: impl Into<PathBuf>) -> &mut Self
pub fn cwd(&mut self, path: impl Into<PathBuf>) -> &mut Self
Working directory for the child process.
Sourcepub fn env(
&mut self,
key: impl Into<OsString>,
val: impl Into<OsString>,
) -> &mut Self
pub fn env( &mut self, key: impl Into<OsString>, val: impl Into<OsString>, ) -> &mut Self
Set an environment variable for the child process.
Sourcepub fn stdin(&mut self, data: impl Into<Vec<u8>>) -> &mut Self
pub fn stdin(&mut self, data: impl Into<Vec<u8>>) -> &mut Self
Provide data to be piped to the child’s stdin.
Sourcepub fn run(&mut self) -> Result<P4Output>
pub fn run(&mut self) -> Result<P4Output>
Execute the command and collect output.
Stdout and stderr are read concurrently in separate OS threads to
prevent pipe-full deadlocks. If a timeout was set,
the process is killed once the deadline is reached.
Sourcepub fn stream(&mut self) -> Result<P4Stream>
pub fn stream(&mut self) -> Result<P4Stream>
Run the command and return a streaming iterator over output lines.
Stdout and stderr are read concurrently by two OS threads and merged
into a single stream. The final event is always
P4StreamEvent::Exit with the exit code (unless the stream is
dropped early).
Unlike run, this method does not support
timeout — the caller controls iteration and can
drop the stream to cancel.