vmi_core/core/
memory_access.rsuse serde::{Deserialize, Serialize};
bitflags::bitflags! {
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct MemoryAccess: u8 {
const R = 0b00000001;
const W = 0b00000010;
const X = 0b00000100;
const RW = Self::R.bits() | Self::W.bits();
const WX = Self::W.bits() | Self::X.bits();
const RX = Self::R.bits() | Self::X.bits();
const RWX = Self::R.bits() | Self::W.bits() | Self::X.bits();
}
}
impl std::fmt::Display for MemoryAccess {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let mut result = [b'-'; 3];
if self.contains(MemoryAccess::R) {
result[0] = b'r';
}
if self.contains(MemoryAccess::W) {
result[1] = b'w';
}
if self.contains(MemoryAccess::X) {
result[2] = b'x';
}
f.write_str(unsafe { std::str::from_utf8_unchecked(&result) })
}
}