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
use core::alloc::AllocError;
use alloc::collections::TryReserveError;
#[derive(Debug, Copy, Clone)]
pub enum Error {
OutOfMemory(&'static str),
Forbidden(&'static str),
NotFound(&'static str),
BadRequest(&'static str),
Timeout(&'static str),
Conflict(&'static str),
Gone(&'static str),
InternalError(&'static str),
InsufficientStorage(&'static str),
NotImplemented(&'static str),
SegmentFault,
}
pub type Result<T> = core::result::Result<T, Error>;
impl From<AllocError> for Error {
fn from(x: AllocError) -> Self {
Error::OutOfMemory("alloc error")
}
}
impl From<TryReserveError> for Error {
fn from(x: TryReserveError) -> Self {
Error::OutOfMemory("try reserve error")
}
}
impl From<hashbrown::TryReserveError> for Error {
fn from(x: hashbrown::TryReserveError) -> Self {
Error::OutOfMemory("try reserve error")
}
}