Skip to main content

ApiV1

Struct ApiV1 

Source
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

Source

pub fn version(&self) -> &WSLVersion

Retpurns the current version of the WSL API being used.

This is useful for checking compatibility with specific API features.

§Example
let api_v1: ApiV1 = ...;
let version = api_v1.version();
println!(
    "WSL API version: {}.{}.{}",
    version.Major, version.Minor, version.Revision
);
Source

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")?;
Source

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.

Trait Implementations§

Source§

impl AsRef<ApiV1> for WSLPluginAPIV1

Source§

fn as_ref(&self) -> &ApiV1

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<WSLPluginAPIV1> for ApiV1

Source§

fn as_ref(&self) -> &WSLPluginAPIV1

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for ApiV1

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ApiV1> for WSLPluginAPIV1

Source§

fn from(value: ApiV1) -> Self

Converts to this type from the input type.
Source§

impl From<WSLPluginAPIV1> for ApiV1

Source§

fn from(value: WSLPluginAPIV1) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for ApiV1

§

impl RefUnwindSafe for ApiV1

§

impl Send for ApiV1

§

impl Sync for ApiV1

§

impl Unpin for ApiV1

§

impl UnsafeUnpin for ApiV1

§

impl UnwindSafe for ApiV1

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more