Skip to main content

Host

Struct Host 

Source
pub struct Host { /* private fields */ }
Expand description

The machine a toolchain check probes.

A Host carries its own environment map (including PATH), a working directory for spawned processes and relative-path lookups, a home directory, and the roots that hold installed platform applications (macOS /Applications). Detection code must read all of those through this value so a declared host cannot leak real-machine state into a check.

Implementations§

Source§

impl Host

Source

pub fn current() -> Self

The real machine this process runs on.

§Panics

Panics when the process has no current directory.

Source

pub fn new<P, K, V>( path_dirs: impl IntoIterator<Item = P>, vars: impl IntoIterator<Item = (K, V)>, ) -> Self
where P: AsRef<Path>, K: AsRef<OsStr>, V: AsRef<OsStr>,

A host declared entirely by the arguments.

PATH is exactly path_dirs; the environment contains exactly vars plus that PATH entry. The working directory defaults to the process cwd — override it with Host::with_cwd. The home directory is taken from the declared HOME/USERPROFILE; a host that declares neither has none. Declared hosts have no Host::app_dirs, so application- bundle fallbacks (e.g. Android Studio’s bundled JBR) cannot fire.

On Windows the process-spawn plumbing variables (SystemRoot, SystemDrive, windir, ComSpec, PATHEXT) are seeded from the running process because children cannot start without them; they describe how to launch a process, never what is installed.

§Panics

Panics when path_dirs cannot be joined into a PATH string (e.g. an entry containing the platform separator).

Source

pub fn with_cwd(self, cwd: impl Into<PathBuf>) -> Self

Override the working directory (builder-style).

Source

pub fn with_app_dirs(self, app_dirs: impl IntoIterator<Item = PathBuf>) -> Self

Override the application-install roots (builder-style).

Source

pub fn env(&self, key: impl AsRef<OsStr>) -> Option<&OsStr>

An environment variable on this host.

Lookup is case-sensitive on Unix and case-insensitive on Windows, matching the platform’s own environment semantics.

Source

pub fn env_string(&self, key: impl AsRef<OsStr>) -> Option<String>

An environment variable decoded as UTF-8 text.

Source

pub fn path_entries(&self) -> Vec<PathBuf>

This host’s PATH entries, in order.

Empty components are dropped: an empty PATH element historically means “the working directory”, which would let tools sitting in Host::cwd masquerade as installed on a declared host.

Source

pub fn cwd(&self) -> &Path

Working directory for spawned processes and relative-path lookups.

Source

pub fn home_dir(&self) -> Option<&Path>

This host’s home directory, when it declares one.

Source

pub fn current_exe() -> Result<PathBuf>

Path of the running water executable.

A fact about this process rather than the declared machine — every Host reports the same binary, which is what RUSTC_WRAPPER self-wrapping must name. Associated with Host so the probe stays inside the seam.

§Errors

Returns an error when the OS cannot report the executable’s path.

Source

pub fn app_dirs(&self) -> &[PathBuf]

Roots holding installed platform application bundles.

/Applications on macOS, empty elsewhere and on declared hosts. Probes that look inside installed .app bundles read them under these roots so test machines do not leak real-machine installs.

Source

pub async fn which(&self, name: impl AsRef<OsStr>) -> Result<PathBuf, Error>

Locate name on this host’s PATH.

Never consults the process PATH: a host with no PATH or an empty one reports every tool as missing.

§Errors
  • which::Error when no executable named name exists on this host.
Source

pub fn with_env(&self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>) -> Self

A host whose environment additionally binds key to value.

Use for variables that must reach a single child tree (for example WATERUI_SKIP_RUST_BUILD on the xcodebuild invocation) instead of mutating the process environment.

Source

pub fn command(&self, program: impl AsRef<OsStr>) -> Command

A Command that runs program under this host’s environment.

The child sees exactly this host’s variables and starts in Host::cwd; program is resolved against this host’s PATH. stdio configuration is left to the caller — see [crate::utils::command] for the CLI’s capture/inherit policy.

Source

pub fn std_command(&self, program: impl AsRef<OsStr>) -> Command

A std::process::Command that runs program under this host.

Same environment and working directory as Host::command, for the places that need synchronous or std-only command features (process groups, spawning from a non-async thread).

Source

pub async fn output( &self, program: impl AsRef<OsStr>, args: impl IntoIterator<Item = impl AsRef<OsStr>>, ) -> Result<Output, CommandError>

Spawn program with args under this host, capturing output.

stdout and stderr are piped and always collected for the returned Output; when the CLI’s --logs passthrough is active each chunk is additionally mirrored to the terminal as it arrives, matching the historical run_command_output_os behavior.

§Errors
§Panics

Panics if the piped-stdio invariant above is violated — both streams are configured piped immediately before spawn, so take() always sees Some.

Source

pub async fn run( &self, program: impl AsRef<OsStr>, args: impl IntoIterator<Item = impl AsRef<OsStr>>, ) -> Result<String, CommandError>

Run program under this host and return stdout as text.

§Errors
Source

pub async fn run_detached( &self, program: impl AsRef<OsStr>, args: impl IntoIterator<Item = impl AsRef<OsStr>>, ) -> Result<ExitStatus, CommandError>

Run program to completion with nothing of this process in its hands: no stdio and, on Windows, no inherited handles at all.

This is how a daemon launcher is run. A child spawned the ordinary way receives every inheritable handle this process holds — including strays our own parent passed down — and hands them on to whatever it spawns with inheritance on. adb start-server is the case that matters: its server outlives water, and a pipe it inherited stays open until the server exits. The exit status is the caller’s to judge, because a launcher’s own output is discarded here.

§Errors

CommandError::Spawn when the program cannot be started or waited on.

Trait Implementations§

Source§

impl Clone for Host

Source§

fn clone(&self) -> Host

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 Debug for Host

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Host

§

impl RefUnwindSafe for Host

§

impl Send for Host

§

impl Sync for Host

§

impl Unpin for Host

§

impl UnsafeUnpin for Host

§

impl UnwindSafe for Host

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more