1use std::fmt;
4use thiserror::Error;
5
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum StoreOperation {
9 StoreInit,
10 Persist,
11 PersistLight,
12 PersistFull,
13 Snapshot,
14 Recover,
15 ApplyEvent,
16 ApplyEventOnStop,
17 GetEventsRange,
18 GetLatestEvents,
19 ParseEventKey,
20 EmitPreStopError,
21 EncodeEvent,
22 RollbackPersistLight,
23 DecodeEvent,
24 DecodeState,
25 EncodeActor,
26 ValidateKeyLength,
27 EncryptData,
28 DecryptKey,
29 ValidateCiphertext,
30 DecryptData,
31 Compact,
32 LastEvent,
33 Purge,
34 Delete,
35 LockManagerData,
36 LockData,
37 LockConnection,
38 WalCheckpoint,
39 FlushWal,
40 OpenConnection,
41 Insert,
42 ExecuteBatch,
43 ListCf,
44 ColumnAccess,
45 RocksdbOperation,
46 CreateCollection,
47 CreateState,
48 Test,
49}
50
51impl fmt::Display for StoreOperation {
52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53 let value = match self {
54 Self::StoreInit => "store_init",
55 Self::Persist => "persist",
56 Self::PersistLight => "persist_light",
57 Self::PersistFull => "persist_full",
58 Self::Snapshot => "snapshot",
59 Self::Recover => "recover",
60 Self::ApplyEvent => "apply_event",
61 Self::ApplyEventOnStop => "apply_event_on_stop",
62 Self::GetEventsRange => "get_events_range",
63 Self::GetLatestEvents => "get_latest_events",
64 Self::ParseEventKey => "parse_event_key",
65 Self::EmitPreStopError => "emit_prestop_error",
66 Self::EncodeEvent => "encode_event",
67 Self::RollbackPersistLight => "rollback_persist_light",
68 Self::DecodeEvent => "decode_event",
69 Self::DecodeState => "decode_state",
70 Self::EncodeActor => "encode_actor",
71 Self::ValidateKeyLength => "validate_key_length",
72 Self::EncryptData => "encrypt_data",
73 Self::DecryptKey => "decrypt_key",
74 Self::ValidateCiphertext => "validate_ciphertext",
75 Self::DecryptData => "decrypt_data",
76 Self::Compact => "compact",
77 Self::LastEvent => "last_event",
78 Self::Purge => "purge",
79 Self::Delete => "delete",
80 Self::LockManagerData => "lock_manager_data",
81 Self::LockData => "lock_data",
82 Self::LockConnection => "lock_connection",
83 Self::WalCheckpoint => "wal_checkpoint",
84 Self::FlushWal => "flush_wal",
85 Self::OpenConnection => "open_connection",
86 Self::Insert => "insert",
87 Self::ExecuteBatch => "execute_batch",
88 Self::ListCf => "list_cf",
89 Self::ColumnAccess => "column_access",
90 Self::RocksdbOperation => "rocksdb_operation",
91 Self::CreateCollection => "create_collection",
92 Self::CreateState => "create_state",
93 Self::Test => "test",
94 };
95 f.write_str(value)
96 }
97}
98
99#[derive(Clone, Debug, Error, PartialEq, Eq)]
101pub enum Error {
102 #[error("failed to create store: {reason}")]
106 CreateStore { reason: String },
107
108 #[error("failed to get data for key '{key}': {reason}")]
113 Get { key: String, reason: String },
114
115 #[error("entry not found: {key}")]
117 EntryNotFound { key: String },
118
119 #[error("store operation failed: {operation} - {reason}")]
124 Store {
125 operation: StoreOperation,
126 reason: String,
127 },
128}