[−][src]Struct wslapi::Library
A loaded wslapi.dll
or api-ms-win-wsl-api-l1-1-0.dll
instance
Implementations
impl Library
[src]
pub fn new() -> Result<Self>
[src]
Attempt to load wslapi.dll
pub fn is_distribution_registered(
&self,
distribution_name: impl AsRef<OsStr>
) -> bool
[src]
&self,
distribution_name: impl AsRef<OsStr>
) -> bool
Determines if a distribution is registered with the Windows Subsystem for Linux (WSL).
Arguments
distribution_name
- Unique name representing a distribution (for example, "Fabrikam.Distro.10.01").
Returns
true
if the supplied distribution is currently registeredfalse
otherwise.
See Also
- WslIsDistributionRegistered - the underlying API
pub fn register_distribution(
&self,
distribution_name: impl AsRef<OsStr>,
tar_gz_filename: impl AsRef<Path>
) -> Result<()>
[src]
&self,
distribution_name: impl AsRef<OsStr>,
tar_gz_filename: impl AsRef<Path>
) -> Result<()>
Registers a new distribution with the Windows Subsystem for Linux (WSL).
Consider using wsl --import <Distro> <InstalLocation> <FileName>
instead:
The directory containing the executable will be registered as the BasePath
for rootfs
/ temp
to be placed in.
This odd design choice stems from WslRegisterDistribution itself! Wasn't that a bad choice as far back as Windows XP?
This also limits you to a single registration per executable!
Arguments
distribution_name
- Unique name representing a distribution (for example, "Fabrikam.Distro.10.01").tar_gz_filename
- Full path to a .tar.gz file containing the file system of the distribution to register.
Returns
Err(Error)
- ifdistribution_name
contained'\0'
charactersErr(Error)
- ifdistribution_name
already existedErr(Error)
- iftar_gz_filename
contained'\0'
charactersErr(Error)
- iftar_gz_filename
wasn't an absolute path?Err(Error)
- iftar_gz_filename
wasn't a valid pathErr(Error)
- if the executable's directory already contains a registered distributionErr(Error)
- if the executable's directory wasn't writable?Err(Error)
- if WslRegisterDistribution otherwise failedOk(())
- otherwise
See Also
- WslRegisterDistribution - the underlying API
pub fn unregister_distribution(
&self,
distribution_name: impl AsRef<OsStr>
) -> Result<()>
[src]
&self,
distribution_name: impl AsRef<OsStr>
) -> Result<()>
Unregisters a distribution from the Windows Subsystem for Linux (WSL).
Arguments
distribution_name
- Unique name representing a distribution (for example, "Fabrikam.Distro.10.01").
Returns
Err(Error)
- ifdistribution_name
contained'\0'
charactersErr(Error)
- ifdistribution_name
didn't exist?Err(Error)
- if WslUnregisterDistribution failedOk(())
- otherwise
See Also
- WslUnregisterDistribution - the underlying API
pub fn configure_distribution(
&self,
distribution_name: impl AsRef<OsStr>,
default_uid: ULONG,
wsl_distribution_flags: WSL_DISTRIBUTION_FLAGS
) -> Result<()>
[src]
&self,
distribution_name: impl AsRef<OsStr>,
default_uid: ULONG,
wsl_distribution_flags: WSL_DISTRIBUTION_FLAGS
) -> Result<()>
Modifies the behavior of a distribution registered with the Windows Subsystem for Linux (WSL).
Arguments
distribution_name
- Unique name representing a distribution (for example, "Fabrikam.Distro.10.01").default_uid
- The Linux user ID to use when launching new WSL sessions for this distribution.wsl_distribution_flags
- Flags specifying what behavior to use for this distribution.
Returns
Err(Error)
- ifdistribution_name
contained'\0'
charactersErr(Error)
- ifdistribution_name
didn't exist?Err(Error)
- if WslConfigureDistribution otherwise failed (invalid uid? invalid flags?)Ok(())
- otherwise
Returns
pub fn get_distribution_configuration(
&self,
distribution_name: impl AsRef<OsStr>
) -> Result<Configuration>
[src]
&self,
distribution_name: impl AsRef<OsStr>
) -> Result<Configuration>
Retrieves the current configuration of a distribution registered with the Windows Subsystem for Linux (WSL).
Arguments
distribution_name
- Unique name representing a distribution (for example, "Fabrikam.Distro.10.01").
Returns
Err(Error)
- ifdistribution_name
contained'\0'
charactersErr(Error)
- ifdistribution_name
didn't exist?Err(Error)
- if WslGetDistributionConfiguration failedOk(Configuration { version, default_uid, flags, default_environment_variables })
- otherwise
See Also
- WslGetDistributionConfiguration - the underlying API
- Configuration - the returned struct
pub fn launch_interactive(
&self,
distribution_name: impl AsRef<OsStr>,
command: impl AsRef<OsStr>,
use_current_working_directory: bool
) -> Result<DWORD>
[src]
&self,
distribution_name: impl AsRef<OsStr>,
command: impl AsRef<OsStr>,
use_current_working_directory: bool
) -> Result<DWORD>
Launches an interactive Windows Subsystem for Linux (WSL) process in the context of a particular distribution. This differs from Library::launch in that the end user will be able to interact with the newly-created process.
Arguments
distribution_name
- Unique name representing a distribution (for example, "Fabrikam.Distro.10.01").command
- Command to execute. If no command is supplied, launches the default shell.use_current_working_directory
- Governs whether or not the launched process should inherit the calling process's working directory. Iffalse
, the process is started in the WSL default user's home directory ("~").
Returns
Err(Error)
- ifdistribution_name
contained'\0'
charactersErr(Error)
- ifdistribution_name
didn't exist?Err(Error)
- ifcommand
contained'\0'
charactersErr(Error)
- if WslLaunchInteractive otherwise failedOk(DWORD)
- the exit code of the process after it exits.
See Also
- Library::launch - non-interactive, programatic interaction
- WslLaunchInteractive - the underlying API
pub fn launch<I, O, E>(
&self,
distribution_name: impl AsRef<OsStr>,
command: impl AsRef<OsStr>,
use_current_working_directory: bool,
stdin: I,
stdout: O,
stderr: E
) -> Result<Process> where
I: TryInto<Stdio>,
I::Error: Display,
O: TryInto<Stdio>,
O::Error: Display,
E: TryInto<Stdio>,
E::Error: Display,
[src]
&self,
distribution_name: impl AsRef<OsStr>,
command: impl AsRef<OsStr>,
use_current_working_directory: bool,
stdin: I,
stdout: O,
stderr: E
) -> Result<Process> where
I: TryInto<Stdio>,
I::Error: Display,
O: TryInto<Stdio>,
O::Error: Display,
E: TryInto<Stdio>,
E::Error: Display,
Launches a Windows Subsystem for Linux (WSL) process in the context of a particular distribution.
Arguments
distribution_name
- Unique name representing a distribution (for example, "Fabrikam.Distro.10.01").command
- Command to execute. If no command is supplied, launches the default shell.use_current_working_directory
- Governs whether or not the launched process should inherit the calling process's working directory. Iffalse
, the process is started in the WSL default user's home directory ("~").stdin
- Handle to use for STDIN.stdout
- Handle to use for STDOUT.stderr
- Handle to use for STDERR.
Returns
Err(Error)
- ifdistribution_name
contained'\0'
charactersErr(Error)
- ifdistribution_name
didn't exist?Err(Error)
- ifcommand
contained'\0'
charactersErr(Error)
- ifstdin
,stdout
, orstderr
failed to convert to StdioErr(Error)
- ifstdin
,stdout
, orstderr
was an invalid handle for WslLaunchErr(Error)
- if WslLaunch otherwise failedOk(Process)
- if the WSL process that launched successfully
See Also
- Process
- Library::launch_interactive - interactive, inherits the same console handles
- WslLaunch - the underlying API
Auto Trait Implementations
impl RefUnwindSafe for Library
impl Send for Library
impl Sync for Library
impl Unpin for Library
impl UnwindSafe for Library
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,