// src/storage_trait.rs use crate::error::DBError; use std::sync::Arc; pub trait StorageBackend: Send + Sync { // Basic key operations fn get(&self, key: &str) -> Result, DBError>; fn set(&self, key: String, value: String) -> Result<(), DBError>; fn setx(&self, key: String, value: String, expire_ms: u128) -> Result<(), DBError>; fn del(&self, key: String) -> Result<(), DBError>; fn exists(&self, key: &str) -> Result; fn keys(&self, pattern: &str) -> Result, DBError>; fn dbsize(&self) -> Result; fn flushdb(&self) -> Result<(), DBError>; fn get_key_type(&self, key: &str) -> Result, DBError>; // Scanning fn scan(&self, cursor: u64, pattern: Option<&str>, count: Option) -> Result<(u64, Vec<(String, String)>), DBError>; fn hscan(&self, key: &str, cursor: u64, pattern: Option<&str>, count: Option) -> Result<(u64, Vec<(String, String)>), DBError>; // Hash operations fn hset(&self, key: &str, pairs: Vec<(String, String)>) -> Result; fn hget(&self, key: &str, field: &str) -> Result, DBError>; fn hgetall(&self, key: &str) -> Result, DBError>; fn hdel(&self, key: &str, fields: Vec) -> Result; fn hexists(&self, key: &str, field: &str) -> Result; fn hkeys(&self, key: &str) -> Result, DBError>; fn hvals(&self, key: &str) -> Result, DBError>; fn hlen(&self, key: &str) -> Result; fn hmget(&self, key: &str, fields: Vec) -> Result>, DBError>; fn hsetnx(&self, key: &str, field: &str, value: &str) -> Result; // List operations fn lpush(&self, key: &str, elements: Vec) -> Result; fn rpush(&self, key: &str, elements: Vec) -> Result; fn lpop(&self, key: &str, count: u64) -> Result, DBError>; fn rpop(&self, key: &str, count: u64) -> Result, DBError>; fn llen(&self, key: &str) -> Result; fn lindex(&self, key: &str, index: i64) -> Result, DBError>; fn lrange(&self, key: &str, start: i64, stop: i64) -> Result, DBError>; fn ltrim(&self, key: &str, start: i64, stop: i64) -> Result<(), DBError>; fn lrem(&self, key: &str, count: i64, element: &str) -> Result; // Expiration fn ttl(&self, key: &str) -> Result; fn expire_seconds(&self, key: &str, secs: u64) -> Result; fn pexpire_millis(&self, key: &str, ms: u128) -> Result; fn persist(&self, key: &str) -> Result; fn expire_at_seconds(&self, key: &str, ts_secs: i64) -> Result; fn pexpire_at_millis(&self, key: &str, ts_ms: i64) -> Result; // Metadata fn is_encrypted(&self) -> bool; fn info(&self) -> Result, DBError>; // Clone to Arc for sharing fn clone_arc(&self) -> Arc; }