1use std::error::Error;
3use std::fmt::{self, Display, Formatter};
4
5use base::Unsigned6Bit;
6use base::charset::DescribedChar;
7
8use super::alarm::Alarm;
9
10#[derive(Debug)]
12pub enum InputEvent {
13 PetrMountPaperTape { data: Vec<u8> },
14 LwKeyboardInput { data: Vec<Unsigned6Bit> },
15}
16
17#[derive(Debug)]
19pub enum InputEventError {
20 BufferUnavailable,
28
29 InputOnUnattachedUnit,
36
37 InputEventNotValidForDevice,
38 InvalidReentrantCall,
39
40 Alarm(Alarm),
41}
42
43impl Display for InputEventError {
44 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
45 match self {
46 InputEventError::BufferUnavailable => f.write_str("buffer unavailable"),
47 InputEventError::InputOnUnattachedUnit => {
48 f.write_str("input on a unit which is not attached")
49 }
50 InputEventError::InputEventNotValidForDevice => {
51 f.write_str("input event is not valid for this device")
52 }
53 InputEventError::InvalidReentrantCall => f.write_str("inalid re-entrant call"),
54 InputEventError::Alarm(alarm) => alarm.fmt(f),
55 }
56 }
57}
58
59impl Error for InputEventError {}
60
61#[derive(Debug, PartialEq, Eq)]
63pub enum OutputEvent {
64 LincolnWriterPrint {
66 unit: Unsigned6Bit,
67 ch: DescribedChar,
68 },
69}