use std::time::Duration;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum LockError {
#[error("lock acquisition timed out after {0:?}")]
Timeout(Duration),
#[error("lock operation was cancelled")]
Cancelled,
#[error("deadlock detected: {0}")]
Deadlock(String),
#[error("connection error: {0}")]
Connection(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("lock was lost: {0}")]
LockLost(String),
#[error("invalid lock name: {0}")]
InvalidName(String),
#[error("backend error: {0}")]
Backend(#[source] Box<dyn std::error::Error + Send + Sync>),
}
pub type LockResult<T> = Result<T, LockError>;