Skip to main content

digdigdig3_station/
lib.rs

1//! `digdigdig3-station` — Layer 2 of the digdigdig3 workspace.
2//!
3//! High-level consumer-facing builder over [`digdigdig3::connector_manager::ExchangeHub`].
4//! See `docs/plans/station-architecture.md` for design, `docs/plans/station-phase-1-plan.md`
5//! for the phase-by-phase implementation roadmap.
6//!
7//! Phase 1 scope (current): skeleton only. Modules below are stubs.
8
9pub mod backfill;
10pub use backfill::fetch_history;
11pub mod ws_health;
12pub use ws_health::WsHealth;
13pub mod builder;
14pub mod settings;
15pub mod cache;
16pub mod data;
17pub(crate) mod derived;
18pub mod error;
19pub mod persistence;
20pub mod quota;
21pub mod series;
22pub mod station;
23pub mod subscription;
24
25// Modules moved from dig3-core (persistence/cache/cure/OB concerns belong in station)
26pub mod orderbook;
27pub mod rest_cache;
28
29#[cfg(feature = "reconnect")]
30pub mod reconnect;
31
32// OPFS helpers — wasm32 only, shared by store_wasm + manager_wasm.
33#[cfg(target_arch = "wasm32")]
34pub(crate) mod opfs_helpers;
35
36// storage: native uses std::fs; wasm32 uses OPFS-backed manager.
37// On wasm32 only StorageManager / StorageConfig / StreamKey are available;
38// the sub-modules that use std::fs (event_log, rotation, retention, snapshot,
39// index) remain native-only inside storage/mod.rs.
40pub mod storage;
41
42// cure: pure logic over StorageManager — compiles on both targets.
43pub mod cure;
44
45// replay: backed by StorageManager; ws.rs has cfg-split for tokio::spawn /
46// wasm_bindgen_futures::spawn_local and tokio::time::sleep / gloo_timers.
47pub mod replay;
48
49// polling + gap_heal: REST-based; work on wasm via rest_override (Workstream A).
50// spawn_poller uses cfg-split tokio::spawn / wasm_bindgen_futures::spawn_local.
51pub(crate) mod polling;
52
53pub mod gap_heal;
54
55pub use builder::StationBuilder;
56pub use cache::{ticker_cache, CacheConfig, TickerKey};
57pub use error::{Result, StationError};
58pub use persistence::PersistenceConfig;
59pub use series::{DataPoint, Kind, Series, SeriesKey, SharedSeries, SharedSeriesMap};
60pub use quota::{ConsumerHandle, ConsumerQuota, ConsumerWhitelist, QuotaError};
61pub use station::Station;
62pub use subscription::{
63    Event, FailedStream, Stream, SubscribeReport, SubscriptionHandle, SubscriptionSet,
64    WarmupReport,
65};
66
67// DiskStore is available on both targets (native: std::fs; wasm32: OPFS).
68pub use series::DiskStore;
69
70// PollSpec, PollSource, GapHealConfig: available on both targets.
71// polling is now un-gated; gap_heal is un-gated.
72pub use series::PollSpec;
73pub use polling::PollSource;
74pub use gap_heal::GapHealConfig;
75
76// StorageManager and friends — available on both targets now.
77pub use storage::{StorageConfig, StorageManager, StreamKey};
78
79// EventLog is native-only (std::fs backed).
80#[cfg(not(target_arch = "wasm32"))]
81pub use storage::{EventLog, EventLogIter, EventRecord};
82
83pub use replay::{ReplayHub, ReplayConfig, ReplayRate};
84
85pub use orderbook::{OrderBookTracker, OrderBookError};
86pub use rest_cache::RestCache;
87
88// Settings store — native (file) and wasm32 (OPFS) at API parity.
89pub use settings::{SettingsError, SettingsStore};
90
91pub use cure::{
92    IntegrityChecker, IntegrityReport,
93    Deduper,
94    GapDetector, GapInfo,
95    RepairPipeline, RepairReport,
96};
97
98// Re-export common core types so consumers can build a SubscriptionSet without
99// pulling `digdigdig3` directly.
100pub use digdigdig3::core::types::{AccountType, ExchangeId};
101pub use digdigdig3::SymbolInfo;
102// Re-export Credentials so callers can use add_authenticated without a direct
103// digdigdig3 dependency.
104pub use digdigdig3::core::traits::Credentials;
105// Re-export private DataPoint types for consumers that inspect private events.
106pub use data::{BalanceUpdatePoint, OrderUpdatePoint, PositionUpdatePoint};