io-pass 0.1.0

Owned pass-or-block pipelines with named stages, traces, and single-use pass tokens
Documentation
  • Coverage
  • 100%
    52 out of 52 items documented1 out of 42 items with examples
  • Size
  • Source code size: 19.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 529.8 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hidenoriuehara-art

io-pass

io-pass is a dependency-free Rust library for the logic of passing owned values through named gates and transformations.

use io_pass::{PassResult, Passage, Stage};

let mut passage = Passage::<String, &'static str>::new();
passage.push(Stage::inspect("not empty", |value: &String| {
    if value.is_empty() { Err("empty") } else { Ok(()) }
})?)?;
passage.push(Stage::transform("normalize", |value: String| {
    value.trim().to_lowercase()
})?)?;

let result = passage.run("  PASS  ".to_owned());
assert!(matches!(result, PassResult::Passed(_)));
# Ok::<(), io_pass::Error>(())

Pass principles

  • Every stage receives ownership of one value.
  • A stage must explicitly pass or block.
  • Blocking returns both the value and an application-defined reason.
  • A passage stops at the first block; later stages are not called.
  • Every attempted stage appears in an ordered trace.
  • Stage names are unique so trace entries remain unambiguous.
  • Read-only inspections preserve the value in both branches.
  • Transformations can normalize a value before later gates.
  • PassToken<T> models a single-use handoff through ownership.
  • Empty passages act as identity pipelines.

The crate has no external dependencies and uses no unsafe code.

Licensed under MIT.