Skip to main content

holochain_locksmith/
error.rs

1#[derive(Debug)]
2pub enum LocksmithErrorKind {
3    LocksmithTimeout,
4    LocksmithPoisonError,
5    LocksmithWouldBlock,
6}
7
8#[derive(Debug)]
9pub enum LockType {
10    Lock,
11    Read,
12    Write,
13}
14
15#[derive(Debug)]
16pub struct LocksmithError {
17    lock_type: LockType,
18    kind: LocksmithErrorKind,
19}
20
21impl LocksmithError {
22    pub fn new(lock_type: LockType, kind: LocksmithErrorKind) -> Self {
23        Self { lock_type, kind }
24    }
25}
26
27impl std::fmt::Display for LocksmithError {
28    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29        write!(f, "{}", self)
30    }
31}
32
33impl std::error::Error for LocksmithError {}
34
35pub type LocksmithResult<T> = Result<T, LocksmithError>;