Trait EnvOverride

Source
pub trait EnvOverride: Sized {
    const DEFAULT_ENV_NAME: &'static str;

    // Required methods
    fn parse_version(value: &str) -> Result<Self, ParseVersionError>;
    fn detect_from_host() -> Result<Option<Self>, DetectVirtualPackageError>;

    // Provided methods
    fn parse_version_opt(
        value: &str,
    ) -> Result<Option<Self>, DetectVirtualPackageError> { ... }
    fn from_env_var_name_or<F>(
        env_var_name: &str,
        fallback: F,
    ) -> Result<Option<Self>, DetectVirtualPackageError>
       where F: FnOnce() -> Result<Option<Self>, DetectVirtualPackageError> { ... }
    fn detect_with_fallback<F>(
        ov: &Override,
        fallback: F,
    ) -> Result<Option<Self>, DetectVirtualPackageError>
       where F: FnOnce() -> Result<Option<Self>, DetectVirtualPackageError> { ... }
    fn detect(
        ov: Option<&Override>,
    ) -> Result<Option<Self>, DetectVirtualPackageError> { ... }
}
Expand description

Traits for overridable virtual packages Use as Cuda::detect(override)

Required Associated Constants§

Source

const DEFAULT_ENV_NAME: &'static str

Default name of the environment variable that overrides the virtual package.

Required Methods§

Source

fn parse_version(value: &str) -> Result<Self, ParseVersionError>

Parse env_var_value

Source

fn detect_from_host() -> Result<Option<Self>, DetectVirtualPackageError>

Detect the virtual package for the current system. This method is here so that <Self as EnvOverride>::current always returns the same error type. current may return different types of errors depending on the virtual package. This one always returns DetectVirtualPackageError.

Provided Methods§

Source

fn parse_version_opt( value: &str, ) -> Result<Option<Self>, DetectVirtualPackageError>

Helper to convert the output of parse_version and handling empty strings.

Source

fn from_env_var_name_or<F>( env_var_name: &str, fallback: F, ) -> Result<Option<Self>, DetectVirtualPackageError>

Read the environment variable and if it exists, try to parse it with EnvOverride::parse_version If the output is:

  • None, then the environment variable did not exist,
  • Some(Err(None)), then the environment variable exist but was set to zero, so the package should be disabled
  • Some(Ok(pkg)), then the override was for the package.
Source

fn detect_with_fallback<F>( ov: &Override, fallback: F, ) -> Result<Option<Self>, DetectVirtualPackageError>

Apply the override to the current virtual package. If the override is None then use the fallback

Source

fn detect( ov: Option<&Override>, ) -> Result<Option<Self>, DetectVirtualPackageError>

Shortcut for Self::detect_with_fallback with Self::detect_from_host as fallback

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl EnvOverride for Archspec

Source§

const DEFAULT_ENV_NAME: &'static str = "CONDA_OVERRIDE_ARCHSPEC"

Source§

impl EnvOverride for Cuda

Source§

const DEFAULT_ENV_NAME: &'static str = "CONDA_OVERRIDE_CUDA"

Source§

impl EnvOverride for LibC

Source§

const DEFAULT_ENV_NAME: &'static str = "CONDA_OVERRIDE_GLIBC"

Source§

impl EnvOverride for Linux

Source§

const DEFAULT_ENV_NAME: &'static str = "CONDA_OVERRIDE_LINUX"

Source§

impl EnvOverride for Osx

Source§

const DEFAULT_ENV_NAME: &'static str = "CONDA_OVERRIDE_OSX"

Source§

impl EnvOverride for Windows

Source§

const DEFAULT_ENV_NAME: &'static str = "CONDA_OVERRIDE_WIN"