plat#
the platform layer: windows, input, files, threads, network, processes, desktop services -- crate root lib/plat/lib.rs
plat -- the platform layer: one module per OS with the same functions [src/plat]
process: entry point (calls the app's jfgui_main), args(), arg_value(name), exit(code),
std_start() (feature std: the start of a program with std, from its fn main),
write_stdout / write_stderr, time_us(), sleep_ms(ms), date()
environment: env(name) (= getenv), setenv(name, Some / None), config_dir(), temp_dir(), cwd()
folders: user_dir(DIR_DOCUMENTS ..) (desktop, documents, downloads, pictures, music,
videos: Known Folders / XDG user dirs), log_dir() (dirs.rs)
files: read_file(path), write_file(path, data) (native: exclusive sibling + rename),
File::open(path, FO_*) / open_temp(dir) -> read_at / write_at / size / sync,
file_exists(path) (0 / 1 file / 2 dir), mkdir (with parents), delete, rename,
trash (into the recycle bin / freedesktop trash; trash.rs),
file_exists_checked(path) (Some(0) missing, None error), FileLock::acquire(path),
AtomicFile::create(path) -> write_at / commit (write_file in pieces),
dir_list(path, f(name, is_dir, size_lo)) -- checked against the app's
permissions first (guarded.rs); a refused path behaves like a missing one
policy: the app's permissions (apps/NAME/PERMISSIONS): install, the fs / process /
url / plugin / print checks, grants for the user's files (policy.rs)
boot: the app's name, app:// and its manifest at start-up (rt::main! through
rt::boot; ui::main! calls the parts itself) (boot.rs)
vfs: "scheme://path" names in every file function: app:// (the bundled assets),
config:// data:// cache:// logs:// (the app's folders), documents:// and the
other user folders, mem://, mounted providers
(MemFs, DirFs, Overlay, Sub, Bundle); data_dir(), cache_dir() (vfs.rs);
display_name(path); Android content:// (ContentFs, DocHost) (content.rs);
persistent_name(path): a chosen file's name that lasts across restarts (Flatpak's
documents portal: linux_docs.rs)
secret: secret_set / secret_get / secret_delete / secret_available: passwords, tokens and
keys in the system's store (Credential Manager + DPAPI, Secret Service; needs
`secrets` in the manifest) (secret.rs)
instance: claim(app) -> Primary / Forwarded / Alone, take() -> requests of later starts
(the app's single instance; pipe / abstract socket per user) (instance.rs)
spell: sys_spell_find / sys_spell_languages, SysSpeller (check, suggest): the system's
spell checker (Windows ISpellChecker, macOS NSSpellChecker, iOS UITextChecker;
elsewhere none) (spell.rs)
tray: tray_set / tray_remove (the symbol in the notification area, its menu), notify /
notify_close (system notifications), tray_take() -> events (tray.rs)
power: inhibit(reason, INHIBIT_SUSPEND | INHIBIT_IDLE) -> Option<Inhibit> (no standby /
screen saver while the guard lives), inhibited() (power.rs)
autostart: autostart_set(on, args) / autostart_get() / autostart_entry() (Run key, XDG
autostart, Background portal, MSIX StartupTask; needs `autostart` in the manifest)
(autostart.rs)
pkg: packaged() (MSIX, Flatpak, AppImage, Snap or a plain program), msix_updates (App
Installer), FlatpakMonitor / flatpak_spawn_latest (the Flatpak portal),
restart_appimage (pkg.rs)
taskbar: taskbar_progress / taskbar_badge / taskbar_tasks (the taskbar button: progress,
overlay / count, jump list; ITaskbarList3, Unity LauncherEntry), app_user_model_id
/ set_app_user_model_id (Windows: the app's explicit id) (taskbar.rs)
assoc: assoc_register / assoc_conflicts / assoc_unregister: the app's PACKAGE file types
and URL schemes for this program without a setup (HKCU\Software\Classes; .desktop,
shared-mime-info, mimeapps.list), file_uri_path; default_browser_status /
default_browser_request (PACKAGE browser=1) (assoc.rs)
recent: recent_add / recent_list / recent_remove / recent_clear: the system's recent files
(SHAddToRecentDocs and the jump list; recently-used.xbel) (recent.rs)
audio: Stream (open / open_fill, write, start / pause / stop, volume, latency, the default
device followed), play / play_file (WAV, Ogg Vorbis), sound(SOUND_*): the system's
sounds (WASAPI, PulseAudio protocol, WebAudio, AAudio) (audio.rs)
screen: monitors() (rect, work area, dpi, refresh, primary; SET_MONITORS), pick_start (a
pixel's colour anywhere), capture_start (pictures of the screen) (screen.rs)
hotkey: hotkey_register / hotkey_unregister / hotkey_take: global shortcuts (RegisterHotKey,
XGrabKey, the GlobalShortcuts portal) (hotkey.rs)
threads: thread_spawn(stack, f) -> Thread (join), thread_yield(), Sem (post / wait),
wake() (any thread: E_WAKE on the UI thread), wait_events(deadline, on_event)
(headless), cpu_count(), mem_total(); the windows, the clipboard, the dialogs and
the portals belong to the UI thread, the first one that uses them: other threads
panic (ui_only.rs)
pool: thr_init / thr_count / thr_shutdown / thr_self, parallel_for, Job (pool.rs)
task: async execution: Executor (ui() in the event loop, new() / block_on), Task,
spawn_blocking (a pool for blocking work), sleep, CancelToken, Progress, join /
select (task.rs)
aio: files without blocking: read_file / write_file / copy_file with progress and
cancellation, Reader / Writer chunk by chunk (AtomicFile underneath) (aio.rs)
sync: Mutex, Condvar, RwLock, channel (futex / WaitOnAddress; Android too) (sync.rs)
rand: fill_random, random_bytes, random_u64 (the OS CSPRNG) (rand.rs)
net: TcpListener, TcpStream, UdpSocket, SocketAddr, resolve (net.rs)
fs: stat / lstat / read_dir / links / set_times / free_space /
write_file_private / local_zone_id (fs.rs)
cpu: cpu_features() (CPU_*), cpu_brand() (cpu.rs)
crash: crash_hook(Some(f)): f(&CrashInfo) before exit code 3 -- hardware faults (VEH /
signals, the stderr line of ASMLIB) and panics; crash_test() crashes on purpose
windows: the window-indexed API of the assembly (win_create / win_show / win_present /
wait ..., popups, clipboard, drops, pen, cursors; consts.rs, evq.rs, pwin0.rs)
input: (G7a) win_pointer_lock / win_pointer_lock_state / win_raw_motion_take: the pointer
locked to a window, hidden, its raw relative motion (plock.rs); KC_* key_code /
key_label: where a key sits as a USB HID usage on every platform (keycode.rs);
(G7a part 2) pad_watch / pads / pad, E_GAMEPAD: game pads in the W3C standard
layout (pad.rs)
dnd: drag and drop between programs: DragData (files, text, URLs, HTML, image),
the drop target hook, the pending drop, drag_start (dragging out) (dnd.rs)
(plat-shared) print(job) + page layout / PDF writer (print.rs; win_print.rs,
linux_print.rs), plugin libraries lib_open / lib_sym / lib_close / lib_seg and
the crash guard guard_call / guard_run / guard_tag (plib.rs; win_lib.rs,
linux_elfload.rs, linux_guard.rs), monitor_icc / monitor_key (icc.rs), the
portal's file dialog / OpenURI / Print (linux_portal.rs)
(jxl-module) the loadable JPEG XL writer module: jxlenc_set_path / jxlenc_ready /
jxlenc_encode (modhost.rs; the records in modabi.rs)
Where: Windows, Linux, macOS, iOS and Android have every module above (docs/ANDROID.md AN0 to
AN5: on Android threads, the pool, sync, net, fs, watch, certs, printing through the system's
dialog and the system's fonts as on the desktop; process and service are there but answer
ENOTSUP / an error, trash and hard links false, the tray's symbol, global hotkeys, autostart
and the desktop's file types false / Unavailable -- docs/ANDROID.md "Bewusst nicht"; the facade
jflib has every crate there but update). The browser has no process, sync,
fs, service, watch, certs or rand of its own; its net is the page's WebSocket.
The layer knows events, pixel rows, files and threads only -- no UI, no gfx. One of the
four library crates that may contain `unsafe` (rt, simd, plat, gpu); nothing unsafe leaves it
but dl_sym and dl_close (a symbol of a library loaded at run time is the caller's to trust).
Sections
- plat crate root
- plat/process.rs
- plat/process_win.rs (Windows)
- plat/process_linux.rs (Linux)
- plat/process_apple.rs (Apple)
- plat/process_android.rs
- plat/sync.rs
- plat/net.rs
- plat/web_net.rs
- plat/fs.rs
- plat/service.rs
- plat/watch.rs
- plat/certs.rs
- plat/rand.rs
- plat/pid.rs
- plat/hosted.rs
- plat/cpu.rs
- plat/capabilities.rs
- plat/policy.rs
- plat/sandbox.rs
- plat/boot.rs
- plat/vfs.rs
- plat/content.rs
- plat/secret.rs
- plat/instance.rs
- plat/spell.rs
- plat/tray.rs
- plat/sysmenu.rs
- plat/power.rs
- plat/apple_power_ios.rs
- plat/scan.rs
- plat/share.rs
- plat/win_share.rs (Windows)
- plat/sensors.rs
- plat/autostart.rs
- plat/pkg.rs
- plat/linux_flatpak.rs (Linux)
- plat/taskbar.rs
- plat/assoc.rs
- plat/recent.rs
- plat/audio.rs
- plat/win_audio.rs (Windows)
- plat/linux_audio.rs (Linux)
- plat/screen.rs
- plat/hotkey.rs
- plat/present_copy.rs
- plat/log.rs
- plat/a11y.rs
- plat/a11y_wire.rs
- plat/settings.rs
- plat/locale.rs
- plat/guarded.rs
- plat/dirs.rs
- plat/control_stream.rs
- plat/control_ipc_win.rs (Windows)
- plat/control_ipc_linux.rs (Linux)
- plat/control_ipc_apple.rs (Apple)
- plat/pool.rs
- plat/task.rs
- plat/aio.rs
- plat/win.rs (Windows)
- plat/win_api.rs (Windows)
- plat/win_clip.rs (Windows)
- plat/win_filedlg.rs (Windows)
- plat/win_pen.rs (Windows)
- plat/win_touch.rs (Windows)
- plat/win_popup.rs (Windows)
- plat/win_gpuout.rs (Windows)
- plat/win_plock.rs (Windows)
- plat/win_shell.rs (Windows)
- plat/win_test.rs (Windows)
- plat/win_inst.rs (Windows)
- plat/win_screen.rs (Windows)
- plat/win_hotkey.rs (Windows)
- plat/win_uia.rs (Windows)
- plat/win_dnd.rs (Windows)
- plat/win_sys.rs (Windows)
- plat/win_thread.rs (Windows)
- plat/win_print.rs (Windows)
- plat/win_lib.rs (Windows)
- plat/win_pad.rs (Windows)
- plat/win_clr.rs (Windows)
- plat/linux.rs (Linux)
- plat/linux_disp.rs (Linux)
- plat/linux_wl.rs (Linux)
- plat/linux_xkb.rs (Linux)
- plat/linux_x11.rs (Linux)
- plat/linux_portal.rs (Linux)
- plat/linux_ibus.rs (Linux)
- plat/linux_life.rs (Linux)
- plat/linux_pad.rs (Linux)
- plat/linux_sys.rs (Linux)
- plat/linux_thread.rs (Linux)
- plat/linux_print.rs (Linux)
- plat/linux_elfload.rs (Linux)
- plat/linux_glibc.rs (Linux)
- plat/linux_gpuout.rs (Linux)
- plat/apple.rs (Apple)
- plat/apple_sys.rs (Apple)
- plat/apple_thread.rs (Apple)
- plat/apple_disp.rs (Apple)
- plat/apple_ios_services.rs (Apple)
- plat/apple_ios_share.rs (Apple)
- plat/apple_ios_a11y.rs (Apple)
- plat/apple_ios_pad.rs (Apple)
- plat/apple_mac.rs (Apple)
- plat/apple_mac_test.rs (Apple)
- plat/apple_mac_dnd.rs (Apple)
- plat/apple_mac_app.rs (Apple)
- plat/apple_mac_pad.rs (Apple)
- plat/apple_mac_gpu.rs (Apple)
- plat/apple_mac_scan.rs (Apple)
- plat/apple_mac_screen.rs (Apple)
- plat/apple_mac_share.rs (Apple)
- plat/apple_mac_a11y.rs (Apple)
- plat/web.rs
- plat/android_files.rs
- plat/web_files.rs
- plat/android_host.rs
- plat/web_windows.rs
- plat/web_screen.rs
- plat/web_system.rs
- plat/web_sensors.rs
- plat/android_gpu.rs
- plat/apple_ios_gpu.rs
- plat/web_gpu.rs
- plat/android_ime.rs
- plat/android_edges.rs
- plat/web_threads.rs
- plat/android_thread.rs
- plat/android_print.rs
- plat/clipdrop.rs
- plat/fuzz.rs
- plat/dnd.rs
- plat/cliprich.rs
- plat/consts.rs
- plat/evq.rs
- plat/keycode.rs
- plat/plock.rs
- plat/pad.rs
- plat/ime.rs
- plat/icc.rs
- plat/pwin0.rs
- plat/plib.rs
- plat/print.rs
- plat/modhost.rs
- plat/modabi.rs