JFLib

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

Source: docs/API.md in the JFLib repository.