too/backend/
dummy.rs

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
use crate::{
    math::{vec2, Vec2},
    Backend, Command, Event, EventReader,
};

/// A dummy backend that does nothing
pub struct DummyBackend;

impl Backend for DummyBackend {
    type Out<'a> = std::io::Empty;

    fn size(&self) -> Vec2 {
        vec2(80, 25)
    }

    fn should_draw(&self) -> bool {
        true
    }

    fn command(&mut self, _cmd: Command) {}

    fn writer(&mut self) -> Self::Out<'_> {
        std::io::empty()
    }
}

impl EventReader for DummyBackend {
    fn try_read_event(&mut self) -> Option<Event> {
        Some(Event::Quit)
    }
}