diff --git a/Cargo.lock b/Cargo.lock index fb254784b..f3392ae3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2690,6 +2690,7 @@ dependencies = [ "ironrdp-error", "ironrdp-tls", "log", + "thiserror 2.0.18", "tokio", "tokio-tungstenite", "tokio-util", diff --git a/crates/ironrdp-mstsgu/Cargo.toml b/crates/ironrdp-mstsgu/Cargo.toml index d1f9a0234..9e6186a92 100644 --- a/crates/ironrdp-mstsgu/Cargo.toml +++ b/crates/ironrdp-mstsgu/Cargo.toml @@ -33,6 +33,7 @@ ironrdp-core = { path = "../ironrdp-core", version = "0.1", features = ["std"] } ironrdp-error = { path = "../ironrdp-error", version = "0.1" } ironrdp-tls = { path = "../ironrdp-tls", version = "0.2" } log = "0.4" +thiserror = "2" tokio-tungstenite = { version = "0.29" } tokio-util = { version = "0.7" } tokio = { version = "1.52", features = ["macros", "rt"] } diff --git a/crates/ironrdp-mstsgu/src/lib.rs b/crates/ironrdp-mstsgu/src/lib.rs index 805dda69a..20625accb 100644 --- a/crates/ironrdp-mstsgu/src/lib.rs +++ b/crates/ironrdp-mstsgu/src/lib.rs @@ -6,8 +6,6 @@ mod macros; mod proto; -use core::fmt; -use core::fmt::Display; use core::pin::Pin; use core::task::Poll; use core::time::Duration; @@ -46,15 +44,22 @@ pub struct GwConnectTarget { type Error = ironrdp_error::Error; -#[derive(Debug)] +#[derive(Debug, thiserror::Error)] #[non_exhaustive] pub enum GwErrorKind { + #[error("invalid GW Target")] InvalidGwTarget, + #[error("connection error")] Connect, + #[error("PacketEOF")] PacketEof, + #[error("unsupported feature")] UnsupportedFeature, + #[error("custom")] Custom, + #[error("encode")] Encode, + #[error("decode")] Decode, } @@ -73,23 +78,6 @@ impl GwErrorExt for ironrdp_error::Error { } } -impl Display for GwErrorKind { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let x = match self { - GwErrorKind::InvalidGwTarget => "invalid GW Target", - GwErrorKind::Connect => "connection error", - GwErrorKind::PacketEof => "PacketEOF", - GwErrorKind::UnsupportedFeature => "unsupported feature", - GwErrorKind::Custom => "custom", - GwErrorKind::Encode => "encode", - GwErrorKind::Decode => "decode", - }; - f.write_str(x) - } -} - -impl core::error::Error for GwErrorKind {} - struct GwConn { client_name: String, target: GwConnectTarget,