1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use std::fmt::Display;

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum NandoKind {
    ReadOnly,
    ReadWrite,
    WriteOnly,
}

impl NandoKind {
    pub fn is_read_only(&self) -> bool {
        match self {
            NandoKind::ReadOnly => true,
            _ => false,
        }
    }

    pub fn is_write_only(&self) -> bool {
        match self {
            NandoKind::WriteOnly => true,
            _ => false,
        }
    }
}

impl Display for NandoKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::ReadOnly => f.write_str("ReadOnly"),
            Self::ReadWrite => f.write_str("ReadWrite"),
            Self::WriteOnly => f.write_str("WriteOnly"),
        }
    }
}

#[derive(Copy, Clone)]
pub struct NandoMetadata {
    pub kind: NandoKind,
    pub spawns_nandos: bool,
    // NOTE if the nanotransaction kind is `WriteOnly` but this is `None`, then we are dealing with
    // some form of varargs.
    pub mutable_argument_indices: Option<&'static [usize]>,
    pub invalidate_on_completion: Option<&'static [usize]>,
}