users/
error.rs

1use core::fmt::Display;
2
3pub type Result<T> = core::result::Result<T, Error>;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6#[repr(C)]
7pub enum Error {
8    DuplicateGroupIdentifier,
9    DuplicateGroupName,
10    DuplicateUserIdentifier,
11    DuplicateUserName,
12    InvalidGroupIdentifier,
13    InvalidUserIdentifier,
14    TooManyGroups,
15    TooManyUsers,
16    PoisonedLock,
17    NotInitialized,
18    AlreadyInitialized,
19}
20
21impl Display for Error {
22    fn fmt(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
23        match self {
24            Self::DuplicateGroupIdentifier => {
25                write!(formatter, "Duplicate group identifier")
26            }
27            Self::DuplicateGroupName => {
28                write!(formatter, "Duplicate group name")
29            }
30            Self::DuplicateUserIdentifier => {
31                write!(formatter, "Duplicate user identifier")
32            }
33            Self::DuplicateUserName => {
34                write!(formatter, "Duplicate user name")
35            }
36            Self::InvalidGroupIdentifier => {
37                write!(formatter, "Invalid group identifier")
38            }
39            Self::InvalidUserIdentifier => {
40                write!(formatter, "Invalid user identifier")
41            }
42            Self::TooManyGroups => {
43                write!(formatter, "Too many groups")
44            }
45            Self::TooManyUsers => {
46                write!(formatter, "Too many users")
47            }
48            Self::PoisonedLock => {
49                write!(formatter, "Poisoned lock")
50            }
51            Self::NotInitialized => {
52                write!(formatter, "Not initialized")
53            }
54            Self::AlreadyInitialized => {
55                write!(formatter, "Already initialized")
56            }
57        }
58    }
59}