Lines Matching defs:path

10 //! use std::path::PathBuf;
27 use std::path;
35 /// Find an executable binary's path by name.
37 /// If given an absolute path, returns it if the file exists and is executable.
39 /// If given a relative path, returns an absolute path to the file if
42 /// If given a string without path separators, looks for a file named
50 /// use std::path::PathBuf;
56 pub fn which<T: AsRef<OsStr>>(binary_name: T) -> Result<path::PathBuf> {
60 /// Find an executable binary's path by name, ignoring `cwd`.
62 /// If given an absolute path, returns it if the file exists and is executable.
66 /// If given a string without path separators, looks for a file named
74 /// use std::path::PathBuf;
80 pub fn which_global<T: AsRef<OsStr>>(binary_name: T) -> Result<path::PathBuf> {
85 pub fn which_all<T: AsRef<OsStr>>(binary_name: T) -> Result<impl Iterator<Item = path::PathBuf>> {
98 ) -> Result<impl Iterator<Item = path::PathBuf>> {
126 /// use std::path::PathBuf;
134 /// Find all cargo subcommand executables on the path:
144 pub fn which_re(regex: impl Borrow<Regex>) -> Result<impl Iterator<Item = path::PathBuf>> {
148 /// Find `binary_name` in the path list `paths`, using `cwd` to resolve relative paths.
149 pub fn which_in<T, U, V>(binary_name: T, paths: Option<U>, cwd: V) -> Result<path::PathBuf>
153 V: AsRef<path::Path>,
174 /// use std::path::PathBuf;
186 ) -> Result<impl Iterator<Item = path::PathBuf>>
197 /// Find all binaries with `binary_name` in the path list `paths`, using `cwd` to resolve relative paths.
202 ) -> Result<impl Iterator<Item = path::PathBuf>>
206 V: AsRef<path::Path>,
215 /// Find all binaries with `binary_name` in the path list `paths`, ignoring `cwd`.
219 ) -> Result<impl Iterator<Item = path::PathBuf>>
239 cwd: Option<either::Either<bool, path::PathBuf>>,
283 /// Sets a custom path for resolving relative paths.
288 pub fn custom_cwd(mut self, cwd: path::PathBuf) -> Self {
297 /// Sets the path name regex to search for. You ***MUST*** call this, or [`Self::binary_name`] prior to searching.
326 /// Sets the path name to search for. You ***MUST*** call this, or [`Self::regex`] prior to searching.
353 pub fn first_result(self) -> Result<path::PathBuf> {
359 pub fn all_results(self) -> Result<impl Iterator<Item = path::PathBuf>> {
370 .map(|i| Box::new(i) as Box<dyn Iterator<Item = path::PathBuf>>);
388 .map(|i| Box::new(i) as Box<dyn Iterator<Item = path::PathBuf>>)
392 /// An owned, immutable wrapper around a `PathBuf` containing the path of an executable.
395 /// advantage of being a type distinct from `std::path::Path` and `std::path::PathBuf`.
397 /// It can be beneficial to use `which::Path` instead of `std::path::Path` when you want the type
398 /// system to enforce the need for a path that exists and points to a binary that is executable.
400 /// Since `which::Path` implements `Deref` for `std::path::Path`, all methods on `&std::path::Path`
404 inner: path::PathBuf,
408 /// Returns the path of an executable binary by name.
422 /// Returns the path of an executable binary by name in the path list `paths` and using the
430 V: AsRef<path::Path>,
435 /// Returns all paths of an executable binary by name in the path list `paths` and using the
447 V: AsRef<path::Path>,
452 /// Returns a reference to a `std::path::Path`.
453 pub fn as_path(&self) -> &path::Path {
457 /// Consumes the `which::Path`, yielding its underlying `std::path::PathBuf`.
458 pub fn into_path_buf(self) -> path::PathBuf {
470 type Target = path::Path;
472 fn deref(&self) -> &path::Path {
477 impl AsRef<path::Path> for Path {
478 fn as_ref(&self) -> &path::Path {
489 impl PartialEq<path::PathBuf> for Path {
490 fn eq(&self, other: &path::PathBuf) -> bool {
495 impl PartialEq<Path> for path::PathBuf {
501 /// An owned, immutable wrapper around a `PathBuf` containing the _canonical_ path of an
506 /// `std::path::Path` and `std::path::PathBuf`.
508 /// It can be beneficial to use `CanonicalPath` instead of `std::path::Path` when you want the type
509 /// system to enforce the need for a path that exists, points to a binary that is executable, is
512 /// Since `CanonicalPath` implements `Deref` for `std::path::Path`, all methods on
513 /// `&std::path::Path` are also available to `&CanonicalPath` values.
516 inner: path::PathBuf,
520 /// Returns the canonical path of an executable binary by name.
545 /// Returns the canonical path of an executable binary by name in the path list `paths` and
553 V: AsRef<path::Path>,
560 /// Returns all of the canonical paths of an executable binary by name in the path list `paths` and
572 V: AsRef<path::Path>,
584 /// Returns a reference to a `std::path::Path`.
585 pub fn as_path(&self) -> &path::Path {
589 /// Consumes the `which::CanonicalPath`, yielding its underlying `std::path::PathBuf`.
590 pub fn into_path_buf(self) -> path::PathBuf {
602 type Target = path::Path;
604 fn deref(&self) -> &path::Path {
609 impl AsRef<path::Path> for CanonicalPath {
610 fn as_ref(&self) -> &path::Path {
621 impl PartialEq<path::PathBuf> for CanonicalPath {
622 fn eq(&self, other: &path::PathBuf) -> bool {
627 impl PartialEq<CanonicalPath> for path::PathBuf {