sensehat_screen/
error.rs

1//! Errors for the SenseHat Screen.
2#[cfg(feature = "linux-framebuffer")]
3use framebuffer::FramebufferError;
4#[cfg(feature = "fonts")]
5use std::string::FromUtf16Error;
6
7/// Errors that this crate can return
8#[derive(Debug)]
9pub enum ScreenError {
10    #[cfg(feature = "linux-framebuffer")]
11    Framebuffer(FramebufferError),
12    #[cfg(feature = "fonts")]
13    Unicode(FromUtf16Error),
14}
15
16#[cfg(feature = "linux-framebuffer")]
17impl From<FramebufferError> for ScreenError {
18    fn from(err: FramebufferError) -> ScreenError {
19        ScreenError::Framebuffer(err)
20    }
21}
22
23#[cfg(feature = "fonts")]
24impl From<FromUtf16Error> for ScreenError {
25    fn from(err: FromUtf16Error) -> ScreenError {
26        ScreenError::Unicode(err)
27    }
28}