Skip to main content

hypercall_db/types/
snapshots.rs

1//! Snapshot persistence types.
2//!
3//! Domain types for instrument and portfolio snapshot operations.
4
5use std::collections::HashMap;
6
7/// A snapshot entry row for instruments: symbol -> serialized data.
8#[derive(Debug, Clone)]
9pub struct InstrumentSnapshotEntry {
10    pub symbol: String,
11    pub data: Vec<u8>,
12}
13
14/// A snapshot entry row for portfolio: wallet hex -> serialized data.
15#[derive(Debug, Clone)]
16pub struct PortfolioSnapshotAccountEntry {
17    pub wallet: String,
18    pub data: Vec<u8>,
19}
20
21/// An offset row: stream, partition, offset.
22#[derive(Debug, Clone)]
23pub struct SnapshotOffsetEntry {
24    pub stream: String,
25    pub partition: i32,
26    pub offset: i64,
27}
28
29/// Input for writing an instruments snapshot (all entries + offsets in one go).
30#[derive(Debug, Clone)]
31pub struct InstrumentsSnapshotInput {
32    pub snapshot_type: String,
33    pub entries: Vec<InstrumentSnapshotEntry>,
34    pub offsets: HashMap<String, HashMap<i32, i64>>,
35    pub retention_count: i64,
36}
37
38/// Input for writing a portfolio snapshot (all accounts + offsets in one go).
39#[derive(Debug, Clone)]
40pub struct PortfolioSnapshotInput {
41    pub accounts: Vec<PortfolioSnapshotAccountEntry>,
42    pub offsets: HashMap<String, HashMap<i32, i64>>,
43    pub retention_count: i64,
44}
45
46/// Loaded snapshot data for instruments.
47#[derive(Debug, Clone)]
48pub struct InstrumentsSnapshotData {
49    pub entries: Vec<InstrumentSnapshotEntry>,
50    pub offsets: Vec<SnapshotOffsetEntry>,
51}
52
53/// Loaded snapshot data for portfolio.
54#[derive(Debug, Clone)]
55pub struct PortfolioSnapshotData {
56    pub accounts: Vec<PortfolioSnapshotAccountEntry>,
57    pub offsets: Vec<SnapshotOffsetEntry>,
58}