cratefield_core/ports/
kv.rs1use async_trait::async_trait;
4use std::time::Duration;
5use thiserror::Error;
6
7#[derive(Debug, Clone, Error)]
8pub enum KvError {
9 #[error("key-value operation failed: {0}")]
10 Operation(String),
11}
12
13#[async_trait]
14pub trait KeyValue: Send + Sync {
15 async fn get(&self, key: &str) -> Result<Option<String>, KvError>;
16 async fn put(&self, key: &str, value: &str, ttl: Option<Duration>) -> Result<(), KvError>;
17 async fn delete(&self, key: &str) -> Result<(), KvError>;
18}