Skip to main content

Module api

Module api 

Source
Expand description

High-level, in-process helpers for crates that embed this one as a library.

Sibling hosts such as zpwrchrome-host depend on zwire-host to crawl the filesystem and run commands without speaking the wire protocol or standing up a daemon — they just call these functions and get native Rust values back:

// in zpwrchrome-host:
for entry in zwire_host::api::walk("~/src", Some("rs")) {
    println!("{}", entry.path.display());
}
let out = zwire_host::api::exec("git", ["status", "--porcelain"]).unwrap();
println!("git exited {:?}:\n{}", out.code, String::from_utf8_lossy(&out.stdout));

Everything here is a thin, allocation-light wrapper over the same capability functions the transports call, so behaviour is identical in-process and over the socket.

Structs§

Entry
One node found by walk.
ExecOutput
Captured result of exec.

Functions§

exec
Run program args... to completion in-process and capture its output. Errors carry the failure reason (e.g. the program was not found).
exec_stdin
Run program with input fed to its stdin.
read_file
Read a whole file (~-expandable path) into bytes.
theme_get
The current shared theme as (scheme, ui), where ui is the light/fx object.
theme_set_scheme
Set the shared colour scheme: persist to global.toml (+ the hud-scheme projection) and notify every local subscriber + peer so the fleet follows.
theme_set_ui
Merge a partial light/fx object (e.g. {"light":true}) into the shared ui and notify subscribers + peers. Returns the merged ui.
theme_watch
Watch the shared theme for changes and invoke on_change(scheme, ui) — once immediately (so the caller converges to the current value) and thereafter whenever global.toml changes, from this app or any other. Spawns a background thread and returns at once. An app backend uses this to push live theme updates into its UI (emit a Tauri/JUCE theme-changed event).
walk
Recursively crawl root (a ~-expandable path). ext, when given, keeps only files with that extension (no leading dot). Capped internally so a crawl of a huge tree can’t run away.
walk_filtered
Like walk but with the full filter set: depth, dirs_only, ext, contains (substring match on the leaf name).
write_file
Write bytes to a file (~-expandable path), creating parent dirs.