miden_objects/account/account_id/
id_version.rs1use crate::errors::AccountIdError;
2
3const VERSION_0_NUMBER: u8 = 0;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10#[repr(u8)]
11pub enum AccountIdVersion {
12 Version0 = VERSION_0_NUMBER,
13}
14
15impl AccountIdVersion {
16 pub const fn as_u8(&self) -> u8 {
21 *self as u8
22 }
23}
24
25impl TryFrom<u8> for AccountIdVersion {
26 type Error = AccountIdError;
27
28 fn try_from(value: u8) -> Result<Self, Self::Error> {
29 match value {
30 VERSION_0_NUMBER => Ok(AccountIdVersion::Version0),
31 other_version => Err(AccountIdError::UnknownAccountIdVersion(other_version)),
32 }
33 }
34}
35
36impl From<AccountIdVersion> for u8 {
37 fn from(value: AccountIdVersion) -> Self {
38 value.as_u8()
39 }
40}