pub struct WslInvoker<'runner> { /* private fields */ }Expand description
Runs wsl.exe, through whatever CommandRunner it was given.
Implementations§
Source§impl<'runner> WslInvoker<'runner>
impl<'runner> WslInvoker<'runner>
Sourcepub fn new(
runner: &'runner dyn CommandRunner,
executable: &'runner WslExecutable,
) -> Self
pub fn new( runner: &'runner dyn CommandRunner, executable: &'runner WslExecutable, ) -> Self
Binds a runner and an executable.
Sourcepub fn executable(&self) -> &WslExecutable
pub fn executable(&self) -> &WslExecutable
The executable it will launch.
Sourcepub fn list(&self) -> Result<DistributionTable, WslError>
pub fn list(&self) -> Result<DistributionTable, WslError>
wsl.exe --list --verbose.
§Errors
WslError::Spawn when wsl.exe is not there — which on a Windows
host without WSL is the honest answer — and
WslError::CommandFailed when it ran and refused.
Sourcepub fn exec(&self, command: LinuxCommand) -> Result<CommandOutput, WslError>
pub fn exec(&self, command: LinuxCommand) -> Result<CommandOutput, WslError>
Runs one command inside a distribution.
Takes the command by value, which is not an accident: a
ChildInput is deliberately not Clone, so moving it into the
request is the only way to run it. That both prevents a credential from
being duplicated on the heap by a stray clone() and keeps the
artifact installer from copying a fifteen-megabyte archive on its way
to the pipe.
A non-zero exit is returned as a CommandOutput, not as an error:
several callers here treat “it said no” as information rather than as a
failure.
§Errors
WslError::InvalidName before anything is launched;
WslError::Spawn, WslError::SecretInCommandLine or
WslError::ChildControl from the runner.
Sourcepub fn exec_ok(
&self,
what: &'static str,
command: LinuxCommand,
) -> Result<CommandOutput, WslError>
pub fn exec_ok( &self, what: &'static str, command: LinuxCommand, ) -> Result<CommandOutput, WslError>
Runs one command and refuses anything but a clean exit.
§Errors
As WslInvoker::exec, plus WslError::CommandFailed when the
Linux program exited non-zero, timed out, or was cancelled.
Trait Implementations§
Source§impl<'runner> Clone for WslInvoker<'runner>
impl<'runner> Clone for WslInvoker<'runner>
Source§fn clone(&self) -> WslInvoker<'runner>
fn clone(&self) -> WslInvoker<'runner>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more