1#[derive(Debug, Clone, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
6#[repr(C)]
7pub struct GuestMemoryRegion {
8 pub size: u64,
10 pub ptr: u64,
12}
13
14#[derive(Debug, Clone, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
15#[repr(C)]
16pub struct HyperlightPEB {
17 pub init_data: GuestMemoryRegion,
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23
24 #[test]
25 fn peb_round_trip() {
26 let peb = HyperlightPEB {
27 init_data: GuestMemoryRegion {
28 size: 0x1111,
29 ptr: 0x2222,
30 },
31 };
32 let bytes = bytemuck::bytes_of(&peb);
33 let peb2 = *bytemuck::from_bytes::<HyperlightPEB>(bytes);
34 let peb2_bytes = bytemuck::bytes_of(&peb2);
35 assert_eq!(peb, peb2);
36 assert_eq!(bytes, peb2_bytes);
37 }
38}