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. - Exec
Output - 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
programwithinputfed to its stdin. - read_
file - Read a whole file (
~-expandable path) into bytes. - 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
walkbut 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.