# 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
```rust
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