osom_asm_x86_64/models/
size.rs

1#![allow(non_upper_case_globals)]
2
3use osom_encoders_x86_64::models as enc_models;
4
5/// Represents the size of a general purpose register.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
7#[repr(transparent)]
8#[must_use]
9pub struct Size {
10    value: enc_models::Size,
11}
12
13impl Size {
14    pub const Bit8: Self = Self::new(enc_models::Size::Bit8);
15    pub const Bit16: Self = Self::new(enc_models::Size::Bit16);
16    pub const Bit32: Self = Self::new(enc_models::Size::Bit32);
17    pub const Bit64: Self = Self::new(enc_models::Size::Bit64);
18
19    #[inline(always)]
20    pub(crate) const fn new(size: enc_models::Size) -> Self {
21        Self { value: size }
22    }
23
24    #[inline(always)]
25    #[must_use]
26    pub const fn equals(self, other: Self) -> bool {
27        self.value.equals(other.value)
28    }
29
30    #[inline(always)]
31    pub(crate) fn as_enc_size(self) -> enc_models::Size {
32        self.value
33    }
34}
35
36impl From<enc_models::Size> for Size {
37    #[inline(always)]
38    fn from(size: enc_models::Size) -> Self {
39        Self::new(size)
40    }
41}
42
43impl From<Size> for enc_models::Size {
44    #[inline(always)]
45    fn from(size: Size) -> Self {
46        size.value
47    }
48}