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).
Trait Implementations§
Source§impl<'a> Debug for Controller
impl<'a> Debug for Controller
Auto Trait Implementations§
impl Freeze for Controller
impl !RefUnwindSafe for Controller
impl Send for Controller
impl Sync for Controller
impl Unpin for Controller
impl !UnwindSafe for Controller
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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> IntoAny for T
impl<T> IntoAny for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more