use async_trait::async_trait;
use papaya::HashMapRef;
use std::{error::Error, hash::RandomState, time::Duration};
use super::{
certificates::Certificate,
stored_route::{ReplicaStatus, RoutesSnapshot, StoreError, StoredRoute},
};
#[allow(clippy::double_must_use)]
#[async_trait]
pub trait Store: Send + Sync + 'static {
async fn routes(&self) -> Result<RoutesSnapshot, StoreError>;
async fn revision(&self) -> Result<u64, StoreError>;
#[allow(dead_code)] async fn put_route(&self, route: StoredRoute) -> Result<u64, StoreError>;
#[allow(dead_code)] async fn delete_route(&self, host: &str) -> Result<u64, StoreError>;
async fn report(&self, status: ReplicaStatus, ttl: Duration) -> Result<(), StoreError>;
#[allow(dead_code)] async fn replicas(&self) -> Result<Vec<ReplicaStatus>, StoreError>;
async fn get_certificate(&self, domain: &str) -> Option<Certificate>;
async fn set_certificate(&self, domain: &str, cert: Certificate) -> Result<(), Box<dyn Error>>;
async fn get_certificates(
&self,
) -> HashMapRef<'_, String, Certificate, RandomState, seize::LocalGuard<'_>>;
async fn get_challenge(&self, domain: &str) -> Option<(String, String)>;
async fn set_challenge(
&self,
domain: &str,
token: String,
proof: String,
) -> Result<(), Box<dyn Error>>;
}