PriceLevel v0.7.0
Breaking release — This version introduces significant API changes to improve type safety, correctness, and ergonomics for downstream consumers. See the Migration Guide in the crate docs for full details.
Breaking Changes
Execution Domain Rename (#17 / #8)
Transaction→TradeTransactionList→TradeListtransaction_idfield →trade_id- Parsing prefix
Transaction:→Trade:
Unified Identifier Type (#18 / #9)
- Raw
Uuidreplaced withIdenum supporting UUID, ULID, and sequential (u64) formats. UuidGeneratorfor deterministic trade ID generation.Id::new(),Id::from_u64(),Id::sequential(),Id::from_uuid(),Id::from_ulid().
Domain Newtypes (#19 / #10)
u128price →Pricenewtype (Price::new(),Price::as_u128())u64quantity →Quantitynewtype (Quantity::new(),Quantity::as_u64())u64timestamp →TimestampMsnewtype (TimestampMs::new(),TimestampMs::as_u64())- All support
Display,FromStr,Serialize,Deserialize,from_f64(),to_f64_lossy().
Checked Arithmetic (#20 / #11)
PriceLevel::total_quantity()→Result<u64, PriceLevelError>MatchResult::executed_quantity()→Result<u64, PriceLevelError>MatchResult::executed_value()→Result<u128, PriceLevelError>MatchResult::average_price()→Result<Option<f64>, PriceLevelError>MatchResult::add_trade()→Result<(), PriceLevelError>PriceLevelStatistics::record_execution()→Result<(), PriceLevelError>- No silent saturation or wrapping in financial-critical paths.
Panic-Free Library (#21 / #12)
- Removed all
.unwrap()/.expect()from production modules. - All fallible paths return
Resultwith typedPriceLevelErrorvariants.
Compiler Attributes (#22 / #13)
#[must_use]on all pure/computed public methods.#[repr(u8)]onSideandTimeInForceenums.
Hot-Path Allocation Reduction (#23 / #14)
PriceLevel::iter_orders()now returnsimpl Iterator(wasVec).- New
PriceLevel::snapshot_orders()for when a materializedVecis needed.
Private Fields & Accessor Methods (#24 / #15)
Tradefields privatized → accessor methods (trade_id(),price(),quantity(), etc.)MatchResultfields privatized → accessor methods (order_id(),trades(),remaining_quantity(), etc.)TradeListfields privatized →as_vec(),into_vec(),add(),len(),is_empty()PriceLevelSnapshotfields privatized → accessor methodsPriceLevelSnapshotPackagefields privatized → accessor methods (version(),snapshot(),checksum())
New Error Variants
PriceLevelError::InvalidOperation— checked arithmetic overflow, invalid state transitionsPriceLevelError::SerializationError— JSON/serde serialization failuresPriceLevelError::DeserializationError— JSON/serde deserialization failuresPriceLevelError::ChecksumMismatch— snapshot integrity validation failure
New Features
Snapshot Persistence & Recovery
PriceLevelSnapshotPackagewith SHA-256 checksum protection.PriceLevel::snapshot_to_json()/PriceLevel::from_snapshot_json()for full roundtrip.PriceLevelSnapshotPackage::validate()for checksum verification.
Migration Documentation (#25)
- Comprehensive migration guide added to crate-level docs.
- Old → new API mapping tables with intra-doc links.
- 3 runnable doctest examples (newtypes, checked arithmetic, snapshots).
- Module-level rustdocs for
execution,orders, andprice_levelmodules.
Integration Examples (#31)
- 6 new executable integration examples in
examples/src/bin/:integration_basic_lifecycle— add/update/cancel/match lifecycleintegration_trade_roundtrip— Trade/TradeList/MatchResult serializationintegration_newtypes_contract— Price/Quantity/TimestampMs/Id validationintegration_special_orders— Iceberg/Reserve/PostOnly/TrailingStop/Pegged/MarketToLimitintegration_snapshot_recovery— snapshot persistence, checksum, and corruption detectionintegration_checked_arithmetic— checked arithmetic APIs and error propagation
Benchmark Coverage (#34)
- 6 new benchmark modules in
benches/price_level/:snapshot_recovery— snapshot package creation, JSON roundtrip, checksum validationchecked_arithmetic— total_quantity, executed_quantity, executed_value, average_priceserialization— Trade/TradeList/MatchResult Display/FromStr and serde roundtripsnewtypes— Price/Quantity/TimestampMs/Id construction and parsingspecial_orders— PostOnly, TrailingStop, Pegged, MarketToLimit matchinglifecycle— full add/update/cancel/match/stats cycle benchmarks
Infrastructure
- Upgraded to Rust 2024 edition.
- Version bumped to 0.7.0.
- Workspace dependencies consolidated.
Migration Checklist
- Replace
Transaction/TransactionListwithTrade/TradeList. - Replace raw
UuidwithId; useUuidGeneratorfor trade IDs. - Wrap raw price/quantity/timestamp literals with
Price::new(),Quantity::new(),TimestampMs::new(). - Replace direct field access on
Trade,MatchResult,TradeListwith accessor methods. - Handle
Resultreturns fromtotal_quantity(),executed_quantity(),executed_value(),average_price(), andadd_trade(). - Replace
iter_orders()collecting intoVecwithsnapshot_orders()if needed. - Update snapshot code to use
PriceLevelSnapshotPackagefor checksum validation. - Address new
#[must_use]warnings on query methods.