Skip to main content

PredicateEnv

Trait PredicateEnv 

Source
pub trait PredicateEnv {
    // Required methods
    fn platform(&self) -> Platform;
    fn env(&self, var: &str) -> Option<String>;
    fn command_exists(&self, name: &str) -> bool;
    fn file_exists(&self, path: &Path) -> bool;
    fn resolver(&self) -> &Resolver;
}
Expand description

Environment abstraction used by the predicate evaluator.

Implement this trait to control what the evaluator sees. The default production implementation is DefaultPredicateEnv; a mock suitable for unit tests is MockPredicateEnv.

Required Methods§

Source

fn platform(&self) -> Platform

The platform to match platform:linux / platform:macos / platform:windows against.

Source

fn env(&self, var: &str) -> Option<String>

Look up an environment variable. Returns None when the variable is not set (as opposed to set-but-empty, which returns Some("")).

Source

fn command_exists(&self, name: &str) -> bool

Returns true when name is found on PATH.

Source

fn file_exists(&self, path: &Path) -> bool

Returns true when path exists on the filesystem.

Source

fn resolver(&self) -> &Resolver

The Resolver used to expand ${VAR} tokens in file_exists: paths.

Implementors§