Skip to main content

CommandRequest

Struct CommandRequest 

Source
pub struct CommandRequest { /* private fields */ }
Expand description

One program, one literal argument vector, and the bounds it runs under.

There is no env, no current_dir, and no shell. See the module documentation for why each absence is a control rather than an omission.

There is no Default either, and that absence is the same kind of control: Duration’s default is zero, so a defaulted request would carry a deadline that has already passed and kill every child at the first poll. CommandRequest::new is the only way to build one, and it starts from DEFAULT_TIMEOUT.

Implementations§

Source§

impl CommandRequest

Source

pub fn new(program: impl Into<PathBuf>) -> Self

A request to run program with no arguments.

Source

pub fn arg(self, argument: impl Into<OsString>) -> Self

Appends one argument, verbatim.

Source

pub fn args<I, S>(self, arguments: I) -> Self
where I: IntoIterator<Item = S>, S: Into<OsString>,

Appends several arguments, verbatim and in order.

Source

pub fn with_input(self, input: ChildInput) -> Self

Gives the child something on stdin.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Replaces the default deadline.

Source

pub fn with_limits(self, limits: OutputLimits) -> Self

Replaces the default capture bounds.

Source

pub fn with_cancellation(self, cancellation: Cancellation) -> Self

Lets a caller kill this child before its deadline.

Source

pub fn program(&self) -> &Path

The program that will be launched.

Source

pub fn arguments(&self) -> &[OsString]

The argument vector, in order.

Source

pub fn argument_strings(&self) -> Vec<String>

The argument vector as lossy strings, for assertions and diagnostics.

Source

pub fn input(&self) -> &ChildInput

What the child will see on stdin.

Source

pub fn limits(&self) -> OutputLimits

The capture bounds.

Source

pub fn timeout(&self) -> Duration

The deadline.

Source

pub fn cancellation(&self) -> Option<&Cancellation>

The cancellation flag, when one was attached.

Source

pub fn refuse_payload_in_argv(&self) -> Result<(), WslError>

Refuses the launch when the stdin payload is also in the command line.

The same tripwire as crate::process::SpawnSpec::spawn_with_handoff, and with the same honest limits: it looks for the payload as a verbatim byte substring of the program path and of each argument, and that is all. A payload that is re-encoded, split across two arguments, or normalised differently walks straight past it. It is here because an obvious mistake should fail the launch rather than fail a review — not because passing it is evidence of anything.

Payloads larger than a Windows command line cannot be in one, so they are not scanned.

§Errors

WslError::SecretInCommandLine naming where the payload was found.

Trait Implementations§

Source§

impl Debug for CommandRequest

Debug that cannot print the payload: PipedInput’s own Debug prints a length, and every other field is a program name, an argument, or a bound.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more