1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use thiserror::Error;

#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)]
pub enum InsertError {
    #[error("entry with the provided key already exists")]
    EntryExists,
}

#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)]
pub enum RemoveError {
    #[error("could not find the requested key")]
    KeyNotFound,
    #[error("the removed value does not match the expected one")]
    ValueNotMatching,
}

#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)]
pub enum UpdateError<T>
where
    T: std::error::Error + std::fmt::Debug + 'static,
{
    #[error("could not find the requested key")]
    KeyNotFound,
    #[error("error while updating the value")]
    ValueCallbackError(#[source] T),
}

#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)]
pub enum ReplaceError {
    #[error("could not find the requested key")]
    KeyNotFound,
}