nitro_enclaves/launch/
types.rs1use super::error::*;
4
5use bitflags::bitflags;
6
7#[derive(Debug)]
9pub enum ImageType<'a> {
10 Eif(&'a [u8]),
12}
13
14#[derive(Debug)]
16pub struct MemoryInfo<'a> {
17 pub image_type: ImageType<'a>,
19
20 pub size_mib: usize,
22}
23
24impl<'a> MemoryInfo<'a> {
25 pub fn new(image_type: ImageType<'a>, size_mib: usize) -> Self {
26 Self {
27 image_type,
28 size_mib,
29 }
30 }
31}
32
33bitflags! {
34 #[repr(transparent)]
36 #[derive(Copy, Clone, Default)]
37 pub struct StartFlags: u64 {
38 const DEBUG = 1;
40 }
41}
42
43pub struct PollTimeout(pub i32);
46
47impl TryFrom<(&[u8], usize)> for PollTimeout {
48 type Error = LaunchError;
49
50 fn try_from(args: (&[u8], usize)) -> Result<Self, Self::Error> {
51 let mul = 60 * 1000; let size = args.0.len();
53
54 let file: i32 = ((1 + (size - 1) / (6 << 30)) as i32).saturating_mul(mul);
55 let alloc: i32 = ((1 + (args.1 - 1) / (100 << 30)) as i32).saturating_mul(mul);
56
57 Ok(Self(file + alloc))
58 }
59}
60
61impl From<PollTimeout> for i32 {
62 fn from(arg: PollTimeout) -> i32 {
63 arg.0
64 }
65}