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
//! Interrupts for communicating with the VM from the outside and also for
//! letting the VM communicate with the outside

use std::str::FromStr;
use typedef::*;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum ExternalInterrupt {
    KeyDown(Integer),
    KeyUp,
    MouseDown(Integer),
    MouseUp(Integer),
    Halt,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum InternalInterrupt {
    FlushFramebuffer,
}

impl FromStr for InternalInterrupt {
    type Err = &'static str;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "0" => Ok(InternalInterrupt::FlushFramebuffer),
            _ => Err("unable to parse interrupt"),
        }
    }
}