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 pub guest_heap: GuestMemoryRegion,
19}
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn peb_round_trip() {
27 let peb = HyperlightPEB {
28 init_data: GuestMemoryRegion {
29 size: 0x1111,
30 ptr: 0x2222,
31 },
32 guest_heap: GuestMemoryRegion {
33 size: 0x3333,
34 ptr: 0x4444,
35 },
36 };
37 let bytes = bytemuck::bytes_of(&peb);
38 let peb2 = *bytemuck::from_bytes::<HyperlightPEB>(bytes);
39 let peb2_bytes = bytemuck::bytes_of(&peb2);
40 assert_eq!(peb, peb2);
41 assert_eq!(bytes, peb2_bytes);
42 }
43}