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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use std::io;
use std::sync::PoisonError;
use thiserror::Error as TError;
#[derive(Debug, TError)]
pub enum Error {
#[error("Error in Sled: {0}")]
Sled(#[from] sled::Error),
#[error("IO error: {0}")]
IO(#[from] io::Error),
#[error("Configuration is invalid")]
InvalidConfiguration,
#[error("RwLock is poisoned")]
Poison,
#[error("UTF8 error")]
Utf8(std::str::Utf8Error),
#[error("String UTF8 error")]
FromUtf8(std::string::FromUtf8Error),
#[error("SystemTime: {0}")]
SystemTime(#[from] std::time::SystemTimeError),
#[error("Message: {0}")]
Message(String),
#[cfg(feature = "json-value")]
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[cfg(feature = "msgpack-value")]
#[error("Msgpack encoding error: {0}")]
MsgpackEncode(#[from] rmp_serde::encode::Error),
#[cfg(feature = "msgpack-value")]
#[error("Msgpack decoding error: {0}")]
MsgpackDecode(#[from] rmp_serde::decode::Error),
#[cfg(feature = "bincode-value")]
#[error("Bincode encoding Error: {0}")]
Bincode(#[from] Box<bincode::ErrorKind>),
#[cfg(feature = "lexpr-value")]
#[error("S-Expression error: {0}")]
Lexpr(#[from] serde_lexpr::Error),
}
impl<T> From<PoisonError<T>> for Error {
fn from(_: PoisonError<T>) -> Error {
Error::Poison
}
}
impl From<std::str::Utf8Error> for Error {
fn from(e: std::str::Utf8Error) -> Error {
Error::Utf8(e)
}
}
impl From<std::string::FromUtf8Error> for Error {
fn from(e: std::string::FromUtf8Error) -> Error {
Error::FromUtf8(e)
}
}
impl From<Error> for sled::transaction::ConflictableTransactionError<Error> {
fn from(e: Error) -> sled::transaction::ConflictableTransactionError<Error> {
sled::transaction::ConflictableTransactionError::Abort(e)
}
}