umbra/
umbra.rs

1use thiserror::Error;
2
3use crate::terminal::{IEvent, TermError, Terminal};
4
5#[derive(Error, Debug)]
6pub enum UError {
7    #[error("Terminal: {0}")]
8    Terminal(TermError),
9}
10
11impl From<TermError> for UError {
12    fn from(err: TermError) -> UError {
13        UError::Terminal(err)
14    }
15}
16
17pub type UResult<T> = std::result::Result<T, UError>;
18
19pub struct Umbra {
20    term: Terminal,
21}
22
23impl Umbra {
24    pub fn new() -> UResult<Self> {
25        Ok(Self {
26            term: Terminal::new()?,
27        })
28    }
29
30    pub fn init(&mut self) -> UResult<()> {
31        Ok(self.term.init()?)
32    }
33
34    pub fn read_event(&mut self) -> UResult<IEvent> {
35        Ok(self.term.read_event()?)
36    }
37}