Expand description
Functions for detecting the environment the application is currently running in.
TODO: A number of these are unimplemented. TODO: How will this interact with subprocesses? If things are checking the CLI directly, it won’t work (a subprocess should still be considered to be running as GUI or CLI for instance even if it’s not actually running those itself).
Re-exports§
pub use detection::EnvironmentCapabilities;pub use detection::EnvironmentIdentity;pub use detection::detect_architecture;pub use detection::detect_capabilities;pub use detection::detect_display_server;pub use detection::detect_identity;
Modules§
- detection
- Platform identity, capability, and display/terminal detection.
Structs§
- EnvDescription
- Serializes to a format where omitted fields assume default values on JSON deserialization. Unknown JSON fields are rejected; JSON is a debugging representation, not a lossless document interchange format.
- Environment
Scope - An RAII guard that establishes an active
EnvDescriptionscope for the current thread’s operation. - Global
Environment Scope - An RAII guard that establishes an active
EnvDescriptionprocess-wide for multi-threaded operations (such as parallel directory traversal).
Enums§
- Format
Id - Standardized format identifier enum derived from formats category tables.
- OsFamily
- Detailed snapshot of the current application and platform environment. Operating system family for platform-specific file attributes, flags, and APIs.
- Process
Role - Process role classification for execution contexts.
Functions§
- advance_
operation_ epoch - Increments the operation epoch, causing any subsequent unscoped calls to
capture_quick_arc()to capture a freshEnvDescriptionsnapshot. - all_
format_ ids - Return all
FormatIdelements representing the active environment. - cached_
local_ ipv4 - Return cached local outbound IPv4 address, discovering if not cached.
- cached_
local_ ipv6 - Return cached local outbound IPv6 address, discovering if not cached.
- cached_
local_ ipv4_ u32 - Return cached local outbound IPv4 address as u32, or 0 if discovery fails.
- cached_
local_ ipv6_ u128 - Return cached local outbound IPv6 address as u128, or 0 if discovery fails.
- cached_
public_ ipv4 - Return cached public IPv4 address, discovering if not cached.
- cached_
public_ ipv6 - Return cached public IPv6 address, discovering if not cached.
- cached_
public_ ipv4_ u32 - Return cached public IPv4 address as u32, or 0 if discovery fails.
- cached_
public_ ipv6_ u128 - Return cached public IPv6 address as u128, or 0 if discovery fails.
- cached_
server_ system_ time_ offset_ nanos - Return cached server system time offset in nanoseconds, discovering if not already cached.
- capabilities
- Return the display, terminal, and renderer capabilities for the active environment.
- capture
- Capture a snapshot of the current execution environment as an
EnvDescription. - capture_
quick - Capture a quick snapshot of the current execution environment as an
EnvDescription, omitting slow or network-dependent queries unless already cached. - capture_
quick_ arc - Returns a shared
Arc<EnvDescription>snapshot of the current environment. - ctb_
version - ctb_
version_ semver - cwd
- env_
cache_ reset - Clear cached IP addresses and server timestamp offset, and immediately refill them.
- get_
boot_ cached_ env - Returns the boot-cached environment recorded during workspace startup, if present.
- get_
process_ role - Get the current process role.
- has_
format - Check if the active execution environment has a specific
FormatId. - identity
- Return the structured OS and platform identity for the active environment.
- init_
boot_ env - Initializes and caches the startup boot environment using a full (slow) environment capture.
- is_
apple_ ios - There does not seem to be a separate iPadOS value for
env::consts::OS. - is_
branded_ build - is_
browser_ vm - Is this a workspace UI running in any VM instance in a browser? (v86, or potentially later other VMs.) Don’t rely on these VM-related methods to check the bit width, the OS, or the display server. It is useful for telling what UI constraints (e.g. available keys - browsers capture some keys) we’re working with. TODO STUB
- is_
browser_ vm_ fullscreen - Is the workspace UI running in a VM in a browser in fullscreen mode? TODO STUB
- is_
browser_ vm_ mobile - Is the workspace UI running in a VM in a mobile browser? TODO STUB
- is_bsd
- Is this a BSD of some sort, not including Darwin?
- is_
cargo_ target_ binary - is_cli
- Is the workspace running with its CLI interface (TTY or videoterminal)?
- is_
cli_ lightweight - Is a lightweight CLI command running (without workspace boot)?
- is_
cli_ tty - Is the workspace running in a TTY (text-mode, but can’t backspace or edit/clear previous lines)?
- is_
cli_ videoterminal - Is the workspace running as a videoterminal/videoterminal emulator (text-mode, but able to edit past lines)?
- is_
darwin - Is running on Darwin family OS?
- is_
debug_ build - is_
dragonfly - Is running on
DragonFlyBSD? - is_
freebsd - Is running on FreeBSD?
- is_gui
- Is the workspace running with its main GUI, regardless of the output mode? Output mode may be browser VM, native window, HTML frames to a browser, headless, etc.
- is_
in_ test - is_
linux - Is running on Linux?
- is_
local - Is this a local client instance, as opposed to the public website server?
- is_
mac_ os_ 10_ or_ newer - Is running on macOS (not classic)?
- is_
netbsd - Is running on NetBSD?
- is_
official_ public_ website - Is this the public website/network services of the official instance?
- is_
official_ signed_ build - Return the cached official signature verification result without network queries. Until explicit verification runs, the build is not trusted.
- is_
openbsd - Is running on OpenBSD?
- is_
public_ website - Is this instance serving the public website and network services?
- is_pwa
- Is the workspace UI running as a PWA?
- is_
pwa_ mobile - Is the workspace UI running as a PWA on mobile?
- is_
release_ build - is_
service_ subprocess - Is this a service subprocess?
- is_tvos
- is_unix
- Is running on Unix-ish OS?
- is_v86
- Is the workspace UI running in v86 in the browser? TODO STUB
- is_
visionos - is_
watchos - is_
webui - Is the workspace running with the prototype web UI? (Page-oriented, not frame-oriented).
- is_
webui_ in_ system_ browser - Is this a prototype web UI running in the system browser?
- is_
webui_ in_ webview - Is this a prototype web UI running in the bundled browser (Linux) or a webview (Mac/Windows)?
- is_
windows - Is running on Windows?
- is_wine
- Is running under the Wine compatibility layer on Windows?
- is_
workspace - Is the workspace running? True even if this is a subprocess, not the main workspace process.
- is_
workspace_ main_ process - Is this the main workspace process?
- local_
ipv4 - Discover the local outbound IPv4 address by querying the routing table.
- local_
ipv6 - Discover the local outbound IPv6 address by querying the routing table.
- looks_
like_ gnustep - Does it look like it’s running in a GNUstep environment? A guess, not confirmed.
- looks_
like_ nextstep_ or_ openstep - Does it look like it’s running in a NeXTSTEP or OPENSTEP environment? A guess, not confirmed.
- os
- Return the OS family
- public_
ipv4 - Discover public IPv4 address by querying the default server IPv4 endpoint.
- public_
ipv6 - Discover public IPv6 address by querying the default server IPv6 endpoint.
- reset_
boot_ cached_ env - Reset the boot-cached environment (primarily used for test isolation).
- reset_
process_ role_ for_ testing - Reset the process role (primarily used for unit testing).
- reset_
quick_ env_ cache - Invalidate the unscoped quick environment snapshot cache without resetting slow network-sourced caches.
- server_
system_ time_ offset_ nanos - Query the official server and return the estimated difference between the client’s clock and the server’s clock in nanoseconds.
- set_
process_ role - Set the current process role.
- summary
- Return a human-readable summary of the active environment.
- unix_
system_ time_ now - Return the current system time in nanoseconds since the Unix epoch.
- unix_
system_ time_ resolution - Detect the resolution of the system clock in nanoseconds.
- usize
- Return the width of usize
- verify_
official_ signed_ build - Verify the running binary by querying the official server. This slow, network-dependent operation is cached once run.
- with_
environment_ scope - Executes a closure within an active thread-local
EnvironmentScope. - with_
global_ environment_ scope - Executes a closure within an active process-wide
GlobalEnvironmentScope.