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
//! Errors for the SenseHat Screen.
#[cfg(feature = "linux-framebuffer")]
use framebuffer::FramebufferError;
#[cfg(feature = "fonts")]
use std::string::FromUtf16Error;

/// Errors that this crate can return
#[derive(Debug)]
pub enum ScreenError {
    #[cfg(feature = "linux-framebuffer")]
    Framebuffer(FramebufferError),
    #[cfg(feature = "fonts")]
    Unicode(FromUtf16Error),
}

#[cfg(feature = "linux-framebuffer")]
impl From<FramebufferError> for ScreenError {
    fn from(err: FramebufferError) -> ScreenError {
        ScreenError::Framebuffer(err)
    }
}

#[cfg(feature = "fonts")]
impl From<FromUtf16Error> for ScreenError {
    fn from(err: FromUtf16Error) -> ScreenError {
        ScreenError::Unicode(err)
    }
}