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
impl Host
Sourcepub fn new<P, K, V>(
path_dirs: impl IntoIterator<Item = P>,
vars: impl IntoIterator<Item = (K, V)>,
) -> Self
pub fn new<P, K, V>( path_dirs: impl IntoIterator<Item = P>, vars: impl IntoIterator<Item = (K, V)>, ) -> Self
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).
Sourcepub fn with_cwd(self, cwd: impl Into<PathBuf>) -> Self
pub fn with_cwd(self, cwd: impl Into<PathBuf>) -> Self
Override the working directory (builder-style).
Sourcepub fn with_app_dirs(self, app_dirs: impl IntoIterator<Item = PathBuf>) -> Self
pub fn with_app_dirs(self, app_dirs: impl IntoIterator<Item = PathBuf>) -> Self
Override the application-install roots (builder-style).
Sourcepub fn env(&self, key: impl AsRef<OsStr>) -> Option<&OsStr>
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.
Sourcepub fn env_string(&self, key: impl AsRef<OsStr>) -> Option<String>
pub fn env_string(&self, key: impl AsRef<OsStr>) -> Option<String>
An environment variable decoded as UTF-8 text.
Sourcepub fn path_entries(&self) -> Vec<PathBuf>
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.
Sourcepub fn current_exe() -> Result<PathBuf>
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.
Sourcepub fn app_dirs(&self) -> &[PathBuf]
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.
Sourcepub async fn which(&self, name: impl AsRef<OsStr>) -> Result<PathBuf, Error>
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::Errorwhen no executable namednameexists on this host.
Sourcepub fn with_env(&self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>) -> Self
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.
Sourcepub fn std_command(&self, program: impl AsRef<OsStr>) -> Command
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).
Sourcepub async fn output(
&self,
program: impl AsRef<OsStr>,
args: impl IntoIterator<Item = impl AsRef<OsStr>>,
) -> Result<Output, CommandError>
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
CommandError::Spawnwhen the program cannot be spawned or awaited.
§Panics
Panics if the piped-stdio invariant above is violated — both streams
are configured piped immediately before spawn, so take() always
sees Some.
Sourcepub async fn run(
&self,
program: impl AsRef<OsStr>,
args: impl IntoIterator<Item = impl AsRef<OsStr>>,
) -> Result<String, CommandError>
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
CommandError::Spawnwhen the program cannot be spawned.CommandError::Failedwhen it exits non-zero; the error embeds the captured stderr/stdout tails.
Sourcepub async fn run_detached(
&self,
program: impl AsRef<OsStr>,
args: impl IntoIterator<Item = impl AsRef<OsStr>>,
) -> Result<ExitStatus, CommandError>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.