Struct which::WhichConfig
source · pub struct WhichConfig { /* private fields */ }
Expand description
A wrapper containing all functionality in this crate.
Implementations§
source§impl WhichConfig
impl WhichConfig
pub fn new() -> Self
sourcepub fn system_cwd(self, use_cwd: bool) -> Self
pub fn system_cwd(self, use_cwd: bool) -> Self
Whether or not to use the current working directory. true
by default.
Panics
If regex was set previously, and you’ve just passed in use_cwd: true
, this will panic.
sourcepub fn custom_cwd(self, cwd: PathBuf) -> Self
pub fn custom_cwd(self, cwd: PathBuf) -> Self
Sets a custom path for resolving relative paths.
Panics
If regex was set previously, this will panic.
sourcepub fn regex(self, regex: Regex) -> Self
pub fn regex(self, regex: Regex) -> Self
Sets the path name regex to search for. You MUST call this, or Self::binary_name
prior to searching.
When Regex
is disabled this function takes the unit type as a stand in. The parameter will change when
Regex
is enabled.
Panics
If the regex
feature wasn’t turned on for this crate this will always panic. Additionally if a
cwd
(aka current working directory) or binary_name
was set previously, this will panic, as those options
are incompatible with regex
.
sourcepub fn binary_name(self, name: OsString) -> Self
pub fn binary_name(self, name: OsString) -> Self
Sets the path name to search for. You MUST call this, or Self::regex
prior to searching.
Panics
If a regex
was set previously this will panic as this is not compatible with regex
.
sourcepub fn custom_path_list(self, custom_path_list: OsString) -> Self
pub fn custom_path_list(self, custom_path_list: OsString) -> Self
Uses the given string instead of the PATH
env variable.
sourcepub fn system_path_list(self) -> Self
pub fn system_path_list(self) -> Self
Uses the PATH
env variable. Enabled by default.
sourcepub fn first_result(self) -> Result<PathBuf>
pub fn first_result(self) -> Result<PathBuf>
Finishes configuring, runs the query and returns the first result.
sourcepub fn all_results(self) -> Result<impl Iterator<Item = PathBuf>>
pub fn all_results(self) -> Result<impl Iterator<Item = PathBuf>>
Finishes configuring, runs the query and returns all results.