Skip to main content

pinocchio_token/state/
account_state.rs

1#[repr(u8)]
2#[derive(Clone, Copy, Debug, PartialEq)]
3pub enum AccountState {
4    /// Account is not yet initialized
5    Uninitialized,
6
7    /// Account is initialized; the account owner and/or delegate may perform
8    /// permitted operations on this account
9    Initialized,
10
11    /// Account has been frozen by the mint freeze authority. Neither the
12    /// account owner nor the delegate are able to perform operations on
13    /// this account.
14    Frozen,
15}
16
17impl From<u8> for AccountState {
18    fn from(value: u8) -> Self {
19        match value {
20            0 => AccountState::Uninitialized,
21            1 => AccountState::Initialized,
22            2 => AccountState::Frozen,
23            _ => panic!("invalid account state value: {value}"),
24        }
25    }
26}
27
28impl From<AccountState> for u8 {
29    fn from(value: AccountState) -> Self {
30        match value {
31            AccountState::Uninitialized => 0,
32            AccountState::Initialized => 1,
33            AccountState::Frozen => 2,
34        }
35    }
36}