elf_utilities/header/
class.rs

1#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2pub enum Class {
3    // invalid class
4    None,
5    // 32bit objects
6    Bit32,
7    // 64bit objects
8    Bit64,
9    Num,
10
11    // for architecture-specific-value
12    Any(u8),
13}
14
15impl Class {
16    pub const INDEX: usize = 4;
17    pub fn to_identifier(&self) -> u8 {
18        match self {
19            Self::None => 0,
20            Self::Bit32 => 1,
21            Self::Bit64 => 2,
22            Self::Num => 3,
23            Self::Any(b) => *b,
24        }
25    }
26}
27
28impl From<u8> for Class {
29    fn from(byte: u8) -> Self {
30        match byte {
31            0 => Self::None,
32            1 => Self::Bit32,
33            2 => Self::Bit64,
34            3 => Self::Num,
35            _ => Self::Any(byte),
36        }
37    }
38}