pub struct PipetteClient { /* private fields */ }Expand description
A client to a running pipette instance inside a VM.
Implementations§
Source§impl PipetteClient
impl PipetteClient
Sourcepub async fn new(
spawner: impl Spawn,
conn: impl 'static + AsyncRead + AsyncWrite + Send + Unpin,
output_dir: &Path,
) -> Result<Self, RecvError>
pub async fn new( spawner: impl Spawn, conn: impl 'static + AsyncRead + AsyncWrite + Send + Unpin, output_dir: &Path, ) -> Result<Self, RecvError>
Connects to a pipette instance inside a VM.
conn must be an established connection over some byte stream (e.g., a
socket).
Sourcepub fn windows_shell(&self) -> WindowsShell<'_>
pub fn windows_shell(&self) -> WindowsShell<'_>
Return a shell object to interact with a Windows guest.
Sourcepub fn unix_shell(&self) -> UnixShell<'_>
pub fn unix_shell(&self) -> UnixShell<'_>
Return a shell object to interact with a Linux guest.
Sourcepub async fn mount(
&self,
source: &str,
target: &str,
fstype: &str,
flags: u64,
mkdir_target: bool,
) -> Result<()>
pub async fn mount( &self, source: &str, target: &str, fstype: &str, flags: u64, mkdir_target: bool, ) -> Result<()>
Mounts a filesystem inside the guest (Linux only).
Sourcepub async fn prepare_chroot(&self, target: &str) -> Result<()>
pub async fn prepare_chroot(&self, target: &str) -> Result<()>
Prepares a chroot by bind-mounting /proc, /dev, and /sys into it,
and mounting a writable tmpfs at /tmp.
Sourcepub fn command(&self, program: impl AsRef<str>) -> Command<'_>
pub fn command(&self, program: impl AsRef<str>) -> Command<'_>
Returns an object used to launch a command inside the guest.
TODO: this is a low-level interface. Make a high-level interface like
xshell::Shell for manipulating the environment and launching
processes.
Sourcepub async fn read_file(&self, path: impl AsRef<str>) -> Result<Vec<u8>>
pub async fn read_file(&self, path: impl AsRef<str>) -> Result<Vec<u8>>
Reads the full contents of a file.
Sourcepub async fn write_file(
&self,
path: impl AsRef<str>,
contents: impl AsyncRead,
) -> Result<()>
pub async fn write_file( &self, path: impl AsRef<str>, contents: impl AsyncRead, ) -> Result<()>
Writes a file to the guest. Note: This may transfer the file in chunks. It is likely not suitable for writing to files that require all content to be written at once, e.g. files in /proc or /sys.
Sourcepub async fn kernel_crash(&self) -> Result<(), RemoteError>
pub async fn kernel_crash(&self) -> Result<(), RemoteError>
Tell the agent to crash the kernel.