Skip to main content

Module NativeHost

Module NativeHost 

Source
Expand description

NativeHost atoms - native OS-layer handlers.

One pub async fn per file. This mod.rs only declares sub-modules; no pub use. Dispatch-site callers bring each atom in via local use.

Modules§

FindFreePort
Wire method: nativeHost:findFreePort. Scans 100 ports starting from Arguments[0] (default 9000) and returns the first free one. Returns 0 when nothing is free in-range so callers can distinguish “search exhausted” from a genuine port 0.
GetColorScheme
Wire method: nativeHost:getColorScheme. Returns { dark, highContrast }. Dark-mode probe covers macOS AppleInterfaceStyle, Windows AppsUseLightTheme, and a Linux ladder (GTK color-scheme → GTK theme name → KDE_COLOR_SCHEME → xfconf). High-contrast probe is Windows HighContrast/Flags and the GNOME a11y high-contrast key; other OSes return false.
IsFullscreen
Wire method: nativeHost:isFullscreen. Returns true if the main webview window is fullscreen. Missing window returns false - this is a read-only probe and should not error.
IsMaximized
Wire method: nativeHost:isMaximized. Returns true if the main webview window is maximized. Missing window returns false (matches VS Code’s behaviour on orphaned calls).
OSProperties
Wire method: nativeHost:getOSProperties (cross-platform). Returns Electron-shaped { type, release, arch, platform, cpus } tuple so VS Code’s os polyfill can continue using the same surface.
OSStatistics
Wire method: nativeHost:getOSStatistics. Returns Electron-shaped { totalmem, freemem, loadavg } snapshot. loadavg is the Unix triple; on Windows it’s [0,0,0] by policy so the caller gets a well-formed array.
OpenExternal
Wire method: native:openExternal, nativeHost:openExternal. Opens an http/https URL in the platform default browser.
PickFolder
Wire method: nativeHost:pickFolderAndOpen, :pickFileAndOpen, :pickFileFolderAndOpen, :pickWorkspaceAndOpen.
ShowItemInFolder
Wire method: native:showItemInFolder, nativeHost:showItemInFolder. Reveals a path in the platform file manager (Finder / Explorer / Linux FM).
ShowOpenDialog
Wire method: nativeHost:showOpenDialog.