Crate ctb_io_environment

Crate ctb_io_environment 

Source
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.
EnvironmentScope
An RAII guard that establishes an active EnvDescription scope for the current thread’s operation.
GlobalEnvironmentScope
An RAII guard that establishes an active EnvDescription process-wide for multi-threaded operations (such as parallel directory traversal).

Enums§

FormatId
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.
ProcessRole
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 fresh EnvDescription snapshot.
all_format_ids
Return all FormatId elements 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 DragonFly BSD?
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.