minos/
lib.rs

1//! Authorization library
2//!
3//! *Warning*: In this crate, all datetimes using `Utc::now`
4pub mod authorization;
5pub mod errors;
6pub mod group;
7pub mod resources;
8pub mod user;
9pub mod utils;
10
11#[cfg(feature = "jwt")]
12pub mod jwt;
13
14#[cfg(feature = "toml_storage")]
15pub mod toml;
16
17#[cfg(test)]
18mod test;
19
20#[derive(PartialEq, Debug, Copy, Clone)]
21pub enum Status {
22    Deleted,
23    Disabled,
24    Inactive,
25    Active,
26}
27
28impl Status {
29    pub fn as_usize(&self) -> usize {
30        *self as usize
31    }
32    pub fn as_u8(&self) -> u8 {
33        *self as u8
34    }
35}
36
37impl From<usize> for Status {
38    fn from(n: usize) -> Status {
39        match n {
40            3 => Status::Active,
41            2 => Status::Inactive,
42            1 => Status::Disabled,
43            _ => Status::Deleted,
44        }
45    }
46}
47
48impl From<u8> for Status {
49    fn from(n: u8) -> Status {
50        match n {
51            3 => Status::Active,
52            2 => Status::Inactive,
53            1 => Status::Disabled,
54            _ => Status::Deleted,
55        }
56    }
57}
58
59impl Default for Status {
60    fn default() -> Self {
61        Self::Inactive
62    }
63}