use std::{fmt::Debug, time::Duration};
use crate::error::DLockError;
#[cfg(feature = "dynamodb")]
pub mod dynamodb;
#[trait_variant::make(Provider: Send)]
pub trait LocalProvider: Clone {
type T;
type L: Lease<Self::L, Self::T>;
type R: Clone;
async fn acquire(
&self,
name: &str,
owner: &str,
duration: &Duration,
retry: Option<Self::R>,
) -> Result<Self::L, DLockError<Self::R>>;
}
#[trait_variant::make(Lease: Send)]
pub trait LocalLease<L, T>: Debug {
async fn release(&self) -> Result<(), DLockError>;
async fn renew(&self) -> Result<L, DLockError>;
fn token(&self) -> T;
}