pub struct ApiV1(/* private fields */);Expand description
The ApiV1 struct provides an interface to interact with version 1 of the WSL Plugin API.
It encapsulates low-level interactions with the API and exposes a safe and idiomatic Rust interface.
Represents a structured interface for interacting with the WSLPluginAPIV1 API.
This struct encapsulates the methods provided by the WSLPluginAPIV1 API, allowing
idiomatic interaction with the Windows Subsystem for Linux (WSL).
Implementations§
Source§impl ApiV1
impl ApiV1
Sourcepub fn version(&self) -> &WSLVersion
pub fn version(&self) -> &WSLVersion
Sourcepub fn mount_folder<WP: AsRef<Path> + Debug, UP: AsRef<Utf8UnixPath> + Debug>(
&self,
session_id: SessionID,
windows_path: WP,
linux_path: UP,
read_only: bool,
name: &OsStr,
) -> WinResult<()>
pub fn mount_folder<WP: AsRef<Path> + Debug, UP: AsRef<Utf8UnixPath> + Debug>( &self, session_id: SessionID, windows_path: WP, linux_path: UP, read_only: bool, name: &OsStr, ) -> WinResult<()>
Create plan9 mount between Windows & Linux Allows sharing a folder between the Windows host and the Linux environment.
§Arguments
session: The current WSL session.windows_path: The Windows path of the folder to be mounted.linux_path: The Linux path where the folder will be mounted.read_only: Whether the mount should be read-only.name: A custom name for the mount.
§Errors
This function returns a windows error when the mount fails.
§Example
api.mount_folder(&session, "C:\\path", "/mnt/path", false, "MyMount")?;Sourcepub fn new_command<'a, P: IntoCowUtf8UnixPath<'a>>(
&'a self,
session_id: SessionID,
program: P,
) -> WSLCommand<'a>
pub fn new_command<'a, P: IntoCowUtf8UnixPath<'a>>( &'a self, session_id: SessionID, program: P, ) -> WSLCommand<'a>
Creates a new WSLCommand associated with this API instance.
This is the preferred way to construct a command to be executed inside WSL.
The returned WSLCommand is bound to:
- this API handle,
- the provided session,
- the specified Linux program path.
§Parameters
session_id: The WSL session in which the command will be executed.program: A Linux (UTF-8, Unix-style) path
§Returns
A WSLCommand builder ready to be configured and executed.
§Notes
- The default execution target is
DistributionID::System. argv[0]defaults to the program path unless explicitly overridden.