pub struct SimplePipe { /* private fields */ }Expand description
A simple pipe that executes a shell command with input on stdin.
§Security Warning
The command string is passed directly to the shell (sh -c on Unix, cmd /C on Windows).
If you construct the command from untrusted input, you risk shell injection attacks.
ⓘ
// DANGEROUS if `user_input` is untrusted:
SimplePipe::new(format!("grep {}", user_input))
// SAFE alternatives:
// 1. Use a fixed command string
SimplePipe::new("grep pattern")
// 2. Validate/sanitize user input before interpolation
let sanitized = sanitize_for_shell(user_input);
SimplePipe::new(format!("grep {}", sanitized))Implementations§
Source§impl SimplePipe
impl SimplePipe
Sourcepub fn new(command: impl Into<String>) -> Self
pub fn new(command: impl Into<String>) -> Self
Create a new pipe that executes the given shell command.
The default mode is PipeMode::Passthrough with a 30-second timeout.
§Security
See the struct-level documentation for shell injection warnings.
pub fn with_timeout(self, timeout: Duration) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimplePipe
impl RefUnwindSafe for SimplePipe
impl Send for SimplePipe
impl Sync for SimplePipe
impl Unpin for SimplePipe
impl UnsafeUnpin for SimplePipe
impl UnwindSafe for SimplePipe
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