1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/******************************************************************************
Author: Joaquín Béjar García
Email: jb@taunais.com
Date: 28/3/25
******************************************************************************/
//! Core price level module: order queue, matching, snapshots, and statistics,
//! lock-free on the match path.
//!
//! This module provides the central [`PriceLevel`] type that represents a single price
//! point in a limit order book. It manages a queue of orders, performs matching (the
//! `Gtc` / `Ioc` / `Day` match path is lock-free), tracks statistics, and supports
//! snapshot persistence with checksum protection. Admissions and updates (cancel / resize)
//! take the shared side of a per-level guard — normally uncontended, but they can block
//! behind an `O(depth)` fill-or-kill match that holds the exclusive side across its
//! feasibility check and sweep so it stays all-or-nothing against concurrent mutation
//! (issue #112).
//!
//! # Key Types
//!
//! - [`PriceLevel`] — the main price level implementation supporting concurrent add, match,
//! update, and cancel operations via atomic counters and crossbeam queues; the
//! `Gtc` / `Ioc` / `Day` match is lock-free, while admissions / updates take a
//! normally-uncontended shared lock that can block behind an `O(depth)` fill-or-kill.
//! - [`PriceLevelData`] — a serializable representation for data transfer and storage.
//! - [`PriceLevelSnapshot`] — a point-in-time snapshot of all orders at a price level.
//! - [`PriceLevelSnapshotPackage`] — a checksum-protected wrapper around a snapshot for
//! safe persistence and recovery via JSON.
//! - [`PriceLevelStatistics`] — real-time execution statistics (orders added/removed/executed,
//! quantity/value executed, average price, waiting times).
//! - [`OrderQueue`] — the underlying lock-free order queue based on crossbeam.
//!
//! # Snapshot Persistence
//!
//! Snapshots can be serialized to JSON with SHA-256 checksum protection:
//!
//! ```rust
//! use pricelevel::PriceLevel;
//!
//! let level = PriceLevel::new(10_000);
//! let json = level.snapshot_to_json().unwrap();
//! let restored = PriceLevel::from_snapshot_json(&json).unwrap();
//! ```
pub use ;
pub use OrderQueue;
pub use ;
pub use PriceLevelStatistics;