Release 0.8.2: expose matchable_quantity + add snapshot_by_seq_into (buffer reuse)#105
Merged
Merged
Conversation
…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.
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_quantityis nowpubIt 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_orderwould 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(): clearsoutand refills it in ascending insertion sequence (the ordermatch_orderconsumes 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 bothPriceLevel(pub) andOrderQueue(pub(crate)); the existingsnapshot_by_seq()now delegates to the_intoform (single walk definition).Housekeeping
Cargo.toml0.8.1→0.8.2.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-Vecvariant.test_snapshot_by_seq_into_reuses_buffer— seeds the buffer non-empty, then reuses it across a smaller and a larger level; assertsclear()(no stale tail) and correct grow/shrink contents.test_matchable_quantity_public_predicts_sweep— the now-public method equals whatmatch_orderactually consumes (depth cap + iceberg replenishment parity).Verification
make pre-pushclean: 415 lib tests (412 + 3 new), 9 proptests, 1 integration, 9 doctests; clippy + fmt + rustdoc-D warningsall green.README.mddiff (item docs only).No new exported type → no
lib.rs/prelude.rsre-export change and no migration-guide entry.