Skip to content

Release 0.8.2: expose matchable_quantity + add snapshot_by_seq_into (buffer reuse)#105

Merged
joaquinbejar merged 2 commits into
mainfrom
issue-104-expose-matchable-snapshot-into
Jun 24, 2026
Merged

Release 0.8.2: expose matchable_quantity + add snapshot_by_seq_into (buffer reuse)#105
joaquinbejar merged 2 commits into
mainfrom
issue-104-expose-matchable-snapshot-into

Conversation

@joaquinbejar

Copy link
Copy Markdown
Owner

Closes #104.

Two small, additive, non-breaking API changes, shipped as 0.8.2. Neither changes existing behavior, dependencies, matching semantics, or the snapshot wire format.

Changes

1. PriceLevel::matchable_quantity is now pub

It was already the deterministic fill-or-kill dry run — a no-mutation replay of the FIFO sweep (including iceberg / reserve replenishment) that returns exactly what match_order would consume. Making it public lets a composing order book delegate per-level all-or-nothing feasibility to this single upstream source of truth instead of re-implementing the sweep and risking drift. Now #[must_use], logic unchanged.

2. snapshot_by_seq_into(&self, out: &mut Vec<Arc<OrderType<()>>>) (buffer reuse)

A buffer-reuse variant of snapshot_by_insertion_seq(): clears out and refills it in ascending insertion sequence (the order match_order consumes orders), so a consumer that walks every level repeatedly (e.g. a self-trade-prevention pre-scan) can reuse one pooled scratch buffer and avoid the per-call allocation. Added on both PriceLevel (pub) and OrderQueue (pub(crate)); the existing snapshot_by_seq() now delegates to the _into form (single walk definition).

Housekeeping

  • Bump Cargo.toml 0.8.10.8.2.
  • New CHANGELOG.md (Keep a Changelog style) with the 0.8.2 entry plus back-fill for 0.8.1 / 0.8.0.

Tests (src/price_level/tests/level.rs)

  • test_snapshot_by_seq_into_matches_snapshot_by_insertion_seq — same sequence as the owned-Vec variant.
  • test_snapshot_by_seq_into_reuses_buffer — seeds the buffer non-empty, then reuses it across a smaller and a larger level; asserts clear() (no stale tail) and correct grow/shrink contents.
  • test_matchable_quantity_public_predicts_sweep — the now-public method equals what match_order actually consumes (depth cap + iceberg replenishment parity).

Verification

  • make pre-push clean: 415 lib tests (412 + 3 new), 9 proptests, 1 integration, 9 doctests; clippy + fmt + rustdoc -D warnings all green.
  • No README.md diff (item docs only).

No new exported type → no lib.rs / prelude.rs re-export change and no migration-guide entry.

…se variant

Make PriceLevel::matchable_quantity public so a composing order book can
delegate per-level fill-or-kill feasibility to the single upstream source
of truth instead of re-deriving the sweep.

Add OrderQueue::snapshot_by_seq_into / PriceLevel::snapshot_by_seq_into:
a buffer-reuse variant of snapshot_by_insertion_seq that clears and refills
a caller-owned Vec in ascending insertion sequence, avoiding the per-call
allocation for consumers that walk every level repeatedly.

Both additive and non-breaking; no change to matching semantics or the
snapshot wire format. Adds tests for sequence parity, buffer reuse
(clear + grow/shrink, no stale tail), and matchable_quantity sweep parity
including iceberg replenishment.
Bump version 0.8.1 -> 0.8.2 and introduce CHANGELOG.md (Keep a Changelog
style) with the 0.8.2 entry plus back-fill for 0.8.1 and 0.8.0.
@joaquinbejar joaquinbejar merged commit 770105c into main Jun 24, 2026
13 checks passed
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/price_level/level.rs 93.12% <100.00%> (+0.30%) ⬆️
src/price_level/order_queue.rs 93.75% <100.00%> (+0.25%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joaquinbejar joaquinbejar deleted the issue-104-expose-matchable-snapshot-into branch June 25, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release 0.8.2: expose matchable_quantity + add snapshot_by_seq_into (buffer reuse) — unblocks OrderBook-rs #136 / #107

2 participants