Skip to main content

ProjectInput

Struct ProjectInput 

Source
#[non_exhaustive]
pub struct ProjectInput<'a> { /* private fields */ }
Expand description

Process-like path inputs used to resolve a project root.

Build one with ProjectInput::new and the chainable setters. Project root resolution is best-effort and uses a stable fallback order:

  1. cwd
  2. parent of exe, for executables that are not known runtimes or tools
  3. parents of absolute paths in cmd

Relative command-line arguments are ignored because they cannot be resolved safely without knowing the process working directory at the time the command started.

The home-directory ceiling is not part of the input. It is configured on StackDetector or passed to resolve_project_root directly.

§Examples

use std::path::Path;
use what_stack::ProjectInput;

let input = ProjectInput::new()
    .cwd(Path::new("/workspace/api/src"))
    .exe(None);

Implementations§

Source§

impl<'a> ProjectInput<'a>

Source

pub const fn new() -> Self

Create an empty input with no path hints.

Source

pub fn cwd(self, cwd: impl Into<Option<&'a Path>>) -> Self

Set the process working directory.

This is the most trustworthy project-root hint and is checked first. Accepts a &Path or an Option<&Path>.

Source

pub fn exe(self, exe: impl Into<Option<&'a Path>>) -> Self

Set the process executable path.

The parent directory is searched when the working directory is missing or does not resolve to a project, unless the executable is a known runtime or tool such as node or python. A root found this way is ignored when it lies in a dot directory directly under the home ceiling, such as ~/.nvm or ~/.cargo. Accepts a &Path or an Option<&Path>.

Source

pub const fn cmd(self, cmd: &'a [OsString]) -> Self

Set the process command-line arguments.

Only absolute path arguments are inspected, in their original order.

Trait Implementations§

Source§

impl<'a> Clone for ProjectInput<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for ProjectInput<'a>

Source§

impl<'a> Debug for ProjectInput<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for ProjectInput<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ProjectInput<'a>

§

impl<'a> RefUnwindSafe for ProjectInput<'a>

§

impl<'a> Send for ProjectInput<'a>

§

impl<'a> Sync for ProjectInput<'a>

§

impl<'a> Unpin for ProjectInput<'a>

§

impl<'a> UnsafeUnpin for ProjectInput<'a>

§

impl<'a> UnwindSafe for ProjectInput<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.