Skip to main content

Crate rusty_pee

Crate rusty_pee 

Source
Expand description

§rusty-pee

A Rust port of the moreutils pee utility: fan a single stdin stream out to N concurrent shell-spawned children, aggregate their exit codes, and surface failures cleanly.

§Quick start

use rusty_pee::{PeeBuilder, CompatibilityMode};
use std::io::Cursor;

// Construct sinks that the builder owns (so they satisfy `'static`).
let sink_a: Vec<u8> = Vec::new();
let sink_b: Vec<u8> = Vec::new();

let mut pee = PeeBuilder::new()
    .sink(Box::new(sink_a))
    .sink(Box::new(sink_b))
    .compat(CompatibilityMode::Default)
    .build()?;

let input = Cursor::new(b"alpha\nbravo\ncharlie\n".to_vec());
pee.run(input)?;

§Stability (lockstep SemVer)

Library and binary share a single crate version. Within 0.x, minor version bumps may introduce breaking changes per standard Cargo semantics. Every public enum and struct is #[non_exhaustive] so variant additions are not breaking changes once 1.0 lands.

§Pipeline-safety contract

When a sink errors mid-chunk during Pee::run, every other live sink receives the complete current chunk in registration order before the failing sink is dropped from the live-set (mirrors the CLI’s --ignore-write-errors default — frozen-on per FR-003).

Re-exports§

pub use error::Error;

Modules§

aggregate
Exit-code aggregation across N child processes.
capture
--capture mode: replace each child’s stdout with a piped handle, buffer to completion, emit captured chunks in argv order after all children exit (FR-017 + AD-007).
cli
Command-line interface — clap derive Cli struct.
error
Library-level error type for rusty_pee.
fanout
Core fan-out write loop (FR-002, FR-003, FR-004, FR-006).
mode
Compatibility mode resolution.
spawner
Per-command shell-wrapping spawn + Stdio::piped() stdin (FR-001).
strict
Strict moreutils-compat mode entry point.

Structs§

Pee
Runtime engine for one pee invocation. Constructed via PeeBuilder.
PeeBuilder
Builder for Pee. All chain methods are #[must_use].

Enums§

CompatibilityMode
Whether to apply Default-mode ergonomic extensions or Strict moreutils parity.

Constants§

BUFSIZ
Default fan-out chunk size (64 KiB per AD-015). Not user-configurable in v0.1.0.

Functions§

run
Binary entry-point helper used by both src/main.rs and src/bin/pee.rs.