vnc/
error.rs

1use thiserror::Error;
2
3#[non_exhaustive]
4#[derive(Debug, Error)]
5pub enum VncError {
6    #[error("Auth is required but no password provided")]
7    NoPassword,
8    #[error("No VNC encoding selected")]
9    NoEncoding,
10    #[error("Unknow VNC security type: {0}")]
11    InvalidSecurityTyep(u8),
12    #[error("Wrong password")]
13    WrongPassword,
14    #[error("Connect error with unknown reason")]
15    ConnectError,
16    #[error("Unknown pixel format")]
17    WrongPixelFormat,
18    #[error("Unkonw server message")]
19    WrongServerMessage,
20    #[error("Image data cannot be decoded correctly")]
21    InvalidImageData,
22    #[error("The VNC client isn't started. Or it is already closed")]
23    ClientNotRunning,
24    #[error(transparent)]
25    IoError(#[from] std::io::Error),
26    #[error("VNC Error with message: {0}")]
27    General(String),
28}
29
30impl<T> From<tokio::sync::mpsc::error::SendError<T>> for VncError {
31    fn from(_value: tokio::sync::mpsc::error::SendError<T>) -> Self {
32        VncError::General("Channel closed".to_string())
33    }
34}