1use fidl_fuchsia_hardware_display_types::ConfigResult;
6
7use futures::channel::mpsc;
8use thiserror::Error;
9
10use crate::controller::VsyncEvent;
11
12#[derive(Error, Debug)]
14pub enum Error {
15 #[error("could not find a display-coordinator device")]
17 DeviceNotFound,
18
19 #[error("device did not enumerate initial displays")]
21 NoDisplays,
22
23 #[error("a singleton task was already initiated")]
26 AlreadyRequested,
27
28 #[error("sysmem buffer collection allocation failed, or invalid response from sysmem")]
30 BuffersNotAllocated,
31
32 #[error("error while setting up a sysmem connection")]
34 SysmemConnection,
35
36 #[error("ran out of identifiers")]
38 IdsExhausted,
39
40 #[error("invalid device path")]
43 DevicePathInvalid,
44
45 #[error("FIDL error: {0}")]
47 FidlError(#[from] fidl::Error),
48
49 #[error("OS I/O error: {0}")]
51 IoError(#[from] std::io::Error),
52
53 #[error("zircon error: {0}")]
55 ZxError(#[from] zx::Status),
56
57 #[error("Device connection error: {0}")]
59 DeviceConnectionError(anyhow::Error),
60
61 #[error("filesystem error: {0}")]
63 FsError(#[from] fuchsia_fs::node::OpenError),
64
65 #[error("failed to create directory watcher: {0}")]
67 WatcherCreateError(#[from] fuchsia_fs::directory::WatcherCreateError),
68
69 #[error("directory watcher stream produced error: {0}")]
71 WatcherStreamError(#[from] fuchsia_fs::directory::WatcherStreamError),
72
73 #[error("failed to notify vsync: {0}")]
75 CouldNotSendVsyncEvent(#[from] mpsc::TrySendError<VsyncEvent>),
76
77 #[error("invalid UTF-8 string")]
79 InvalidUtf8(#[from] std::str::Utf8Error),
80}
81
82pub type Result<T> = std::result::Result<T, Error>;
84
85#[derive(Debug, Error)]
87pub enum ConfigError {
88 #[error("invalid configuration - error_code: {error_code:#?}")]
90 Invalid {
91 error_code: ConfigResult,
93 },
94
95 #[error("FIDL channel error")]
97 Fidl(#[from] fidl::Error),
98}
99
100impl ConfigError {
101 pub fn invalid(error_code: ConfigResult) -> ConfigError {
103 ConfigError::Invalid { error_code }
104 }
105}