endpoint_libs/libs/
error_code.rs1use serde::*;
2
3#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub struct ErrorCode {
6 code: u32,
8}
9
10impl ErrorCode {
11 pub const BAD_REQUEST: Self = Self::new(100400);
13
14 pub const FORBIDDEN: Self = Self::new(100403);
16
17 pub const INTERNAL_ERROR: Self = Self::new(100500);
19
20 pub const NOT_IMPLEMENTED: Self = Self::new(100501);
22
23 pub const fn new(code: u32) -> Self {
25 Self { code }
26 }
27
28 pub const fn to_u32(self) -> u32 {
31 self.code
32 }
33
34 pub const fn code(self) -> u32 {
36 self.to_u32()
37 }
38}