que-luyo 0.1.0

Transactional bite-sized FIFO queue consumption with automatic rollback
Documentation
  • Coverage
  • 100%
    24 out of 24 items documented1 out of 20 items with examples
  • Size
  • Source code size: 13.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 426.96 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hidenoriuehara-art

que-luyo

que-luyo is a dependency-free transactional FIFO queue for taking bite-sized batches without losing work.

The Pakutsuku principle

This crate gives a concrete meaning to パクつく理:

Take only one manageable bite, keep its original order, commit it after success, and put it back untouched when success is not declared.

A Bite temporarily borrows its source queue. Calling commit permanently removes the items. Calling rollback, returning early, unwinding from a panic, or simply dropping the bite restores every item to the front in its original order.

Example

use que_luyo::BiteQueue;

let mut queue = BiteQueue::from_iter(["a", "b", "c"]);

{
    let bite = queue.bite(2)?;
    assert_eq!(bite.iter().copied().collect::<Vec<_>>(), ["a", "b"]);
    // No commit: the bite rolls back when dropped.
}

assert_eq!(queue.iter().copied().collect::<Vec<_>>(), ["a", "b", "c"]);

let committed = queue.bite_exact(2)?.commit();
assert_eq!(committed, ["a", "b"]);
assert_eq!(queue.front(), Some(&"c"));

# Ok::<(), que_luyo::BiteError>(())

Guarantees

  • FIFO order is preserved.
  • A bite never contains more than its requested maximum.
  • Exact bites fail without changing the queue when too few items exist.
  • Uncommitted bites automatically roll back.
  • Zero-sized requests are rejected.
  • The implementation uses only the Rust standard library.

License

MIT