hyperloglog/storage/
mod.rs

1mod file;
2
3#[cfg(feature = "elasticsearch-storage")]
4mod elasticsearch;
5
6pub use file::FileStorage;
7
8#[cfg(feature = "elasticsearch-storage")]
9pub use elasticsearch::ElasticsearchStorage;
10
11use crate::{HyperLogLog, Result};
12use async_trait::async_trait;
13
14/// Storage backend for HyperLogLog structures
15#[async_trait]
16pub trait Storage: Send + Sync {
17    /// Store a HyperLogLog with given key
18    async fn store(&self, key: &str, hll: &HyperLogLog) -> Result<()>;
19
20    /// Load a HyperLogLog by key
21    async fn load(&self, key: &str) -> Result<HyperLogLog>;
22
23    /// Delete a HyperLogLog by key
24    async fn delete(&self, key: &str) -> Result<()>;
25
26    /// Check if a key exists
27    async fn exists(&self, key: &str) -> Result<bool>;
28
29    /// List all keys (for debugging/admin purposes)
30    async fn list_keys(&self) -> Result<Vec<String>>;
31}