vmi_core/
page.rs

1use std::{ops::Deref, rc::Rc};
2
3/// A page of memory that has been mapped from the guest virtual machine.
4#[derive(Clone)]
5pub struct VmiMappedPage(Rc<Box<dyn Deref<Target = [u8]>>>);
6
7impl VmiMappedPage {
8    /// Creates a new mapped page.
9    pub fn new<T>(inner: T) -> Self
10    where
11        T: Deref<Target = [u8]> + 'static,
12    {
13        Self(Rc::new(Box::new(inner)))
14    }
15}
16
17impl Deref for VmiMappedPage {
18    type Target = [u8];
19
20    fn deref(&self) -> &Self::Target {
21        &self.0
22    }
23}
24
25impl AsRef<[u8]> for VmiMappedPage {
26    fn as_ref(&self) -> &[u8] {
27        self.deref()
28    }
29}