P4CLI-20251
A simple Rust library for full-featured P4 (Perforce) CLI with zero pre-install. All errors are propagated via Result without any unwrap.
Features
- Zero pre-install — the p4 binary is embedded as a zstd-compressed asset and extracted at runtime.
- Secure — each instance uses a random-isolated temp directory; binary is written atomically (
write + rename); Unix permissions are0o700. - Concurrent-safe — per-instance temp directories eliminate cross-process file clashes; a content-addressed disk cache avoids repeated decompression.
- Clean exit — child process is always reaped (
wait()), no zombie left behind. - Binary-safe output — raw
Vec<u8>preserves any binary content; UTF-8 helpers provided for text. - Timeout & control —
P4Commandbuilder providestimeout,cwd,env, andstdincontrol. - Platform-conditional dependencies — only the current platform's binary crate is downloaded (~4–5 MB instead of ~23 MB).
Usage
[]
= "0.5.0"
Quick start
use P4Cli;
Builder API (timeout, cwd, env, stdin)
use P4Cli;
use Duration;
P4Output inspection
let out = p4.run?;
// Raw bytes (binary-safe)
let stdout: & = out.stdout;
let stderr: & = out.stderr;
// UTF-8 text helpers
if let Ok = out.stdout_str
// Exit-code check
if out.success else
Supported Platforms
| Target | Binary crate |
|---|---|
| Windows x86_64 | p4cli-20251-win-x64 |
| macOS ARM64 | p4cli-20251-mac-arm64 |
| macOS x86_64 | p4cli-20251-mac-x64 |
| Linux x86_64 | p4cli-20251-linux-x64 |
| Linux ARM64 | p4cli-20251-linux-arm64 |
Only the platform-specific binary crate is downloaded as a dependency — no unnecessary bloat.