pub struct CommandBuilder { /* private fields */ }Expand description
Build a command with a fluent API for more complex configurations.
§Examples
ⓘ
use strike48_connector::process::CommandBuilder;
use std::time::Duration;
let output = CommandBuilder::new("nmap")
.args(&["-sV", "-p", "1-1000", "target.com"])
.timeout(Duration::from_secs(300))
.working_dir("/tmp")
.env("NMAP_PRIVILEGED", "1")
.run()
.await?;Implementations§
Source§impl CommandBuilder
impl CommandBuilder
pub fn new(program: impl Into<String>) -> Self
pub fn arg(self, arg: impl Into<String>) -> Self
pub fn args(self, args: &[&str]) -> Self
pub fn timeout(self, timeout: Duration) -> Self
pub fn working_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn envs(self, vars: HashMap<String, String>) -> Self
pub fn clear_env(self) -> Self
pub fn stdin(self, data: impl Into<Vec<u8>>) -> Self
Sourcepub async fn run(self) -> Result<CommandOutput>
pub async fn run(self) -> Result<CommandOutput>
Run the command and return the output.
Sourcepub async fn run_stdout(self) -> Result<String>
pub async fn run_stdout(self) -> Result<String>
Run the command and return trimmed stdout, failing on non-zero exit.
Auto Trait Implementations§
impl Freeze for CommandBuilder
impl RefUnwindSafe for CommandBuilder
impl Send for CommandBuilder
impl Sync for CommandBuilder
impl Unpin for CommandBuilder
impl UnsafeUnpin for CommandBuilder
impl UnwindSafe for CommandBuilder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request