Expand description
NativeHost atoms - native OS-layer handlers.
One pub async fn Fn per file. This mod.rs only declares sub-modules.
Modules§
- Clipboard
Has - Wire method:
nativeHost:hasClipboard. - Clipboard
Read Buffer - Wire method:
nativeHost:readClipboardBuffer. Binary clipboard not yet implemented - returns empty array. - Clipboard
Read Find Text - Wire method:
nativeHost:readClipboardFindText. macOS has a separate find pasteboard; reuse the general clipboard for parity with VS Code on Linux/Windows. - Clipboard
Read Image - Wire method:
nativeHost:readImage. Binary image clipboard not yet implemented - returns empty array. - Clipboard
Read Text - Wire method:
nativeHost:readClipboardText. - Clipboard
Trigger Paste - Wire method:
nativeHost:triggerPaste. Tauri 2.x has no direct paste API - returns false so callers fall through to the OS native paste shortcut. - Clipboard
Write Buffer - Wire method:
nativeHost:writeClipboardBuffer. Binary clipboard not yet implemented - no-op. - Clipboard
Write Find Text - Wire method:
nativeHost:writeClipboardFindText. - Clipboard
Write Text - Wire method:
nativeHost:writeClipboardText. - Exit
nativeHost:exit- exit with an explicit code. VS Code calls this fromNativeHostMainService.exit(code)when an extension or the workbench requests a non-zero exit (crash reporter, restart-on-crash sentinel, etc.).- Find
Free Port - Wire method:
nativeHost:findFreePort. Scans 100 ports starting fromArguments[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. - GetColor
Scheme - Wire method:
nativeHost:getColorScheme. Returns{ dark, highContrast }. Dark-mode probe covers macOSAppleInterfaceStyle, WindowsAppsUseLightTheme, and a Linux ladder (GTK color-scheme → GTK theme name →KDE_COLOR_SCHEME→ xfconf). High-contrast probe is WindowsHighContrast/Flagsand the GNOME a11yhigh-contrastkey; other OSes return false. - GetEnvironment
Paths - Wire method:
nativeHost:getEnvironmentPaths. Returns paths used by VS Code’sResolveConfigurationto locate user-data, logs, home, and temp directories. The session-timestamped logs subdirectory is created on first call so VS Code can write output files immediately. - Install
Shell Command nativeHost:installShellCommand- create aland(orcode) symlink in/usr/local/binpointing at the running executable so the user can launch the editor from a terminal. Mirrors VS Code’s “Install ‘code’ command in PATH” command. Usespkexec/osascriptto acquire elevated privileges when/usr/local/binis not writable by the current user.- IsFullscreen
- Wire method:
nativeHost:isFullscreen. Returns true if themainwebview 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 themainwebview window is maximized. Missing window returns false (matches VS Code’s behaviour on orphaned calls). - IsRunning
UnderAR M64Translation - Wire method:
nativeHost:isRunningUnderARM64Translation. On macOS checkssysctl.proc_translated(Rosetta 2). Cached viaOnceLock- translation status is stable for the process lifetime. - Kill
Process nativeHost:killProcess- send SIGKILL (Unix) or TerminateProcess (Windows) to a child process. VS Code uses this to forcibly stop language servers and debug adapters that don’t respond to graceful shutdown within their timeout.- Move
Item ToTrash - Wire method:
nativeHost:moveItemToTrash. Routes deletions to the OS trash bin so they are recoverable. macOS uses Finder via osascript; Linux prefersgio trashthentrash; Windows uses PowerShell Shell.Application. Returnstrueon success. - OSProperties
- Wire method:
nativeHost:getOSProperties(cross-platform). Returns Electron-shaped{ type, release, arch, platform, cpus }tuple. Cached for the process lifetime - OS type, version, arch, and CPU topology are stable; spawningsw_vers/unameon every call wastes ~10 ms each. - OSStatistics
- Wire method:
nativeHost:getOSStatistics. Returns Electron-shaped{ totalmem, freemem, loadavg }snapshot.loadavgis the Unix triple; on Windows it’s[0,0,0]by policy so the caller gets a well-formed array. - Open
DevTools nativeHost:openDevTools- open the WebKit inspector for the main window. Requires thedevtoolsTauri feature (already enabled in the debug profile viaTAURI_DEV_TOOLSenv or cargo feature flag).- Open
External - Wire method:
native:openExternal,nativeHost:openExternal. Opens an http/https URL in the platform default browser. - Pick
Folder - Wire method:
nativeHost:pickFolderAndOpen,:pickFileAndOpen,:pickFileFolderAndOpen,:pickWorkspaceAndOpen. - Quit
nativeHost:quit- save state and gracefully exit the process. VS Code calls this fromILifecycleMainService.quit()on Cmd+Q, File → Quit, and the “Quit” tray item.- Relaunch
nativeHost:relaunch- restart the process with the same argv. VS Code calls this fromILifecycleMainService.relaunch()when an extension update is applied, the user picks “Restart to Apply”, or the workbench triggers a self-restart after a crash.- Reload
nativeHost:reload- reload the webview without restarting the process. VS Code calls this fromILifecycleMainService.reload()for “Reload Window” (Developer menu / Cmd+Shift+P → Reload Window).- Show
Item InFolder - Wire method:
native:showItemInFolder,nativeHost:showItemInFolder. Reveals a path in the platform file manager (Finder / Explorer / Linux FM). - Show
Message Box - Wire method:
nativeHost:showMessageBox. Surfaces a blocking modal message dialog viatauri_plugin_dialog. Returns{ response: 0 }(OK pressed) or{ response: 1 }(dismissed). VS Code destructuresresult.responseto determine which button was chosen. - Show
Open Dialog - Wire method:
nativeHost:showOpenDialog. - Show
Save Dialog - Wire method:
nativeHost:showSaveDialog. Returns{ canceled: bool, filePath?: string }. - Show
Save DialogUI - Wire method:
UserInterface.ShowSaveDialog. Returns bare path string or null so Wind’stypeof Result === "string"guard finds a string value directly. - Toggle
DevTools nativeHost:toggleDevTools- open the inspector if closed, close it if open. Used by the Help → Toggle Developer Tools menu item.- Uninstall
Shell Command nativeHost:uninstallShellCommand- remove thelandsymlink from/usr/local/bin. Mirrors VS Code’s “Uninstall ‘code’ command from PATH”.