use super::types::*;
use crate::error::Result;
use crate::types::events::SettlementEvent;
pub trait StorageBackend: Send + Sync {
fn open(&mut self) -> Result<()>;
fn close(&mut self);
fn upsert_settlement(&self, event: &SettlementEvent) -> Result<()>;
fn upsert_trade(&self, trade: &TradeRow) -> Result<()>;
fn upsert_trades(&self, trades: &[TradeRow]) -> Result<()>;
fn upsert_positions(&self, wallet: &str, positions: &[serde_json::Value]) -> Result<()>;
fn upsert_onchain_positions(
&self,
wallet: &str,
positions: &[crate::types::rest::OnchainPosition],
) -> Result<()>;
fn wallet_trades(&self, wallet: &str, opts: &QueryOptions) -> Result<Vec<TradeRow>>;
fn wallet_positions(&self, wallet: &str) -> Result<Vec<PositionSummary>>;
fn multi_wallet_positions(
&self,
wallets: &[String],
) -> Result<std::collections::HashMap<String, Vec<PositionSummary>>>;
fn market_trades(&self, condition_id: &str, opts: &QueryOptions) -> Result<Vec<TradeRow>>;
fn market_positions(&self, condition_id: &str) -> Result<Vec<PositionSummary>>;
fn token_trades(&self, token_id: &str, opts: &QueryOptions) -> Result<Vec<TradeRow>>;
fn wallet_settlements(&self, wallet: &str, opts: &QueryOptions) -> Result<Vec<SettlementRow>>;
fn trade_by_tx_hash(&self, tx_hash: &str) -> Result<Vec<TradeRow>>;
fn get_backfill_state(
&self,
entity_type: &str,
entity_id: &str,
) -> Result<Option<BackfillStateRow>>;
fn get_pending_backfills(&self) -> Result<Vec<BackfillStateRow>>;
fn set_backfill_state(&self, state: &BackfillStateRow) -> Result<()>;
fn update_backfill_progress(
&self,
entity_type: &str,
entity_id: &str,
offset: i64,
fetched: i64,
) -> Result<()>;
fn complete_backfill(&self, entity_type: &str, entity_id: &str) -> Result<()>;
fn fail_backfill(&self, entity_type: &str, entity_id: &str, error: &str) -> Result<()>;
fn get_watchlist_snapshot(&self) -> Result<Vec<WatchlistSnapshotRow>>;
fn set_watchlist_snapshot(&self, entries: &[WatchlistSnapshotRow]) -> Result<()>;
fn wallet_token_ids(&self, _wallet: &str) -> Vec<String> {
Vec::new()
}
fn wallet_token_trades(&self, _wallet: &str, _token_id: &str) -> Vec<super::types::TradeRow> {
Vec::new()
}
fn wallet_backfill_complete(&self, _wallet: &str) -> bool {
false
}
fn prune(&self, max_age_seconds: u64) -> Result<usize>;
fn purge_entity(&self, entity_type: &str, entity_id: &str) -> Result<usize>;
fn analyze(&self) -> Result<()>;
fn stats(&self) -> Result<CacheStats>;
}