pub struct Controller { /* private fields */ }
Expand description
A controller for managing a single virtualized guest.
Controller
instantiates a guest on creation and exposes
methods for communicating with the guest. The guest lifetime
is tied to the controller’s; dropping the controller will shutdown
the guest.
Implementations§
Source§impl Controller
impl Controller
Sourcepub async fn new(
name: impl Into<String>,
network: &TestNetwork<'_>,
mac: Option<MacAddress>,
) -> Result<Controller, Error>
pub async fn new( name: impl Into<String>, network: &TestNetwork<'_>, mac: Option<MacAddress>, ) -> Result<Controller, Error>
Instantiates a guest and installs it on the provided network
. If mac
is provided,
the guest will be given the mac address; otherwise one will be picked by virtio.
Returns an error if the sandbox already contains a guest.
Sourcepub async fn put_file(
&self,
local_path: &str,
remote_path: &str,
) -> Result<(), Error>
pub async fn put_file( &self, local_path: &str, remote_path: &str, ) -> Result<(), Error>
Copies the file located at local_path
within the namespace of the executing process
to remote_path
on the guest.
Sourcepub async fn get_file(
&self,
local_path: &str,
remote_path: &str,
) -> Result<(), Error>
pub async fn get_file( &self, local_path: &str, remote_path: &str, ) -> Result<(), Error>
Copies the file located at remote_path
on the guest to local_path
within the
namespace of the current process.
Sourcepub async fn exec_with_output_logged(
&self,
command: &str,
env: Vec<EnvironmentVariable>,
input: Option<&str>,
) -> Result<(), Error>
pub async fn exec_with_output_logged( &self, command: &str, env: Vec<EnvironmentVariable>, input: Option<&str>, ) -> Result<(), Error>
Executes command
on the guest with environment variables held in
env
, writing input
into the remote process’s stdin
and logs
the remote process’s stdout and stderr.
Returns an error if the executed command’s exit code is non-zero.
Sourcepub async fn exec(
&self,
command: &str,
env: Vec<EnvironmentVariable>,
input: Option<&str>,
) -> Result<(i32, String, String), Error>
pub async fn exec( &self, command: &str, env: Vec<EnvironmentVariable>, input: Option<&str>, ) -> Result<(i32, String, String), Error>
Executes command
on the guest with environment variables held in env
, writing
input
into the remote process’s stdin
and returning the remote process’s
(stdout, stderr).