Skip to content

Commit df0bf9c

Browse files
authored
fix(pdu)!: remove unused legacy error types (Devolutions#1268)
Remove GccError, McsError, RdpError, SecurityDataError, ClusterDataError, NetworkDataError, CoreDataError, InputEventError, ClientInfoError, CapabilitySetsError, SessionError, and ChannelError. All encode/decode functions had already been migrated to use DecodeResult/EncodeResult from ironrdp-core, leaving these error types as dead code.
1 parent 14c5502 commit df0bf9c

13 files changed

Lines changed: 15 additions & 869 deletions

File tree

crates/ironrdp-pdu/src/gcc/cluster_data.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use core::fmt;
2-
use std::io;
3-
41
use bitflags::bitflags;
52
use ironrdp_core::{
63
Decode, DecodeResult, Encode, EncodeResult, ReadCursor, WriteCursor, ensure_fixed_part_size, invalid_field_err,
@@ -96,33 +93,3 @@ impl RedirectionVersion {
9693
self as u32
9794
}
9895
}
99-
100-
#[derive(Debug)]
101-
pub enum ClusterDataError {
102-
IOError(io::Error),
103-
InvalidRedirectionFlags,
104-
}
105-
106-
impl fmt::Display for ClusterDataError {
107-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
108-
match self {
109-
Self::IOError(_) => f.write_str("IO error"),
110-
Self::InvalidRedirectionFlags => f.write_str("invalid redirection flags field"),
111-
}
112-
}
113-
}
114-
115-
impl core::error::Error for ClusterDataError {
116-
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
117-
match self {
118-
Self::IOError(e) => Some(e),
119-
Self::InvalidRedirectionFlags => None,
120-
}
121-
}
122-
}
123-
124-
impl From<io::Error> for ClusterDataError {
125-
fn from(e: io::Error) -> Self {
126-
Self::IOError(e)
127-
}
128-
}
Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
pub(crate) mod client;
22
pub(crate) mod server;
33

4-
use core::fmt;
5-
use std::io;
6-
7-
use crate::PduError;
8-
94
const VERSION_SIZE: usize = 4;
105

116
#[repr(transparent)]
@@ -41,69 +36,3 @@ impl RdpVersion {
4136
pub const V10_11: Self = Self(0x0008_0010);
4237
pub const V10_12: Self = Self(0x0008_0011);
4338
}
44-
45-
#[derive(Debug)]
46-
pub enum CoreDataError {
47-
IOError(io::Error),
48-
InvalidVersion,
49-
InvalidColorDepth,
50-
InvalidPostBetaColorDepth,
51-
InvalidHighColorDepth,
52-
InvalidSupportedColorDepths,
53-
InvalidSecureAccessSequence,
54-
InvalidKeyboardType,
55-
InvalidEarlyCapabilityFlags,
56-
InvalidConnectionType,
57-
InvalidServerSecurityProtocol,
58-
Pdu(PduError),
59-
}
60-
61-
impl fmt::Display for CoreDataError {
62-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
63-
match self {
64-
Self::IOError(_) => f.write_str("IO error"),
65-
Self::InvalidVersion => f.write_str("invalid version field"),
66-
Self::InvalidColorDepth => f.write_str("invalid color depth field"),
67-
Self::InvalidPostBetaColorDepth => f.write_str("invalid post beta color depth field"),
68-
Self::InvalidHighColorDepth => f.write_str("invalid high color depth field"),
69-
Self::InvalidSupportedColorDepths => f.write_str("invalid supported color depths field"),
70-
Self::InvalidSecureAccessSequence => f.write_str("invalid secure access sequence field"),
71-
Self::InvalidKeyboardType => f.write_str("invalid keyboard type field"),
72-
Self::InvalidEarlyCapabilityFlags => f.write_str("invalid early capability flags field"),
73-
Self::InvalidConnectionType => f.write_str("invalid connection type field"),
74-
Self::InvalidServerSecurityProtocol => f.write_str("invalid server security protocol field"),
75-
Self::Pdu(e) => write!(f, "PDU error: {e}"),
76-
}
77-
}
78-
}
79-
80-
impl core::error::Error for CoreDataError {
81-
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
82-
match self {
83-
Self::IOError(e) => Some(e),
84-
Self::InvalidVersion
85-
| Self::InvalidColorDepth
86-
| Self::InvalidPostBetaColorDepth
87-
| Self::InvalidHighColorDepth
88-
| Self::InvalidSupportedColorDepths
89-
| Self::InvalidSecureAccessSequence
90-
| Self::InvalidKeyboardType
91-
| Self::InvalidEarlyCapabilityFlags
92-
| Self::InvalidConnectionType
93-
| Self::InvalidServerSecurityProtocol
94-
| Self::Pdu(_) => None,
95-
}
96-
}
97-
}
98-
99-
impl From<io::Error> for CoreDataError {
100-
fn from(e: io::Error) -> Self {
101-
Self::IOError(e)
102-
}
103-
}
104-
105-
impl From<PduError> for CoreDataError {
106-
fn from(e: PduError) -> Self {
107-
Self::Pdu(e)
108-
}
109-
}

crates/ironrdp-pdu/src/gcc/mod.rs

Lines changed: 4 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
use core::fmt;
2-
use std::io;
3-
41
use ironrdp_core::{
52
Decode, DecodeErrorKind, DecodeResult, Encode, EncodeResult, ReadCursor, WriteCursor, cast_length, decode,
63
ensure_fixed_part_size, ensure_size, invalid_field_err,
74
};
85
use num_derive::FromPrimitive;
96
use num_traits::FromPrimitive;
107

11-
use crate::PduError;
12-
138
pub mod conference_create;
149

1510
mod cluster_data;
@@ -21,26 +16,22 @@ mod multi_transport_channel_data;
2116
mod network_data;
2217
mod security_data;
2318

24-
pub use self::cluster_data::{ClientClusterData, ClusterDataError, RedirectionFlags, RedirectionVersion};
19+
pub use self::cluster_data::{ClientClusterData, RedirectionFlags, RedirectionVersion};
2520
pub use self::conference_create::{ConferenceCreateRequest, ConferenceCreateResponse};
21+
pub use self::core_data::RdpVersion;
2622
pub use self::core_data::client::{
2723
ClientColorDepth, ClientCoreData, ClientCoreOptionalData, ClientEarlyCapabilityFlags, ColorDepth, ConnectionType,
2824
HighColorDepth, IME_FILE_NAME_SIZE, KeyboardType, SecureAccessSequence, SupportedColorDepths,
2925
};
3026
pub use self::core_data::server::{ServerCoreData, ServerCoreOptionalData, ServerEarlyCapabilityFlags};
31-
pub use self::core_data::{CoreDataError, RdpVersion};
3227
pub use self::message_channel_data::{ClientMessageChannelData, ServerMessageChannelData};
3328
pub use self::monitor_data::{
3429
ClientMonitorData, MONITOR_COUNT_SIZE, MONITOR_FLAGS_SIZE, MONITOR_SIZE, Monitor, MonitorFlags,
3530
};
3631
pub use self::monitor_extended_data::{ClientMonitorExtendedData, ExtendedMonitorInfo, MonitorOrientation};
3732
pub use self::multi_transport_channel_data::{MultiTransportChannelData, MultiTransportFlags};
38-
pub use self::network_data::{
39-
ChannelDef, ChannelName, ChannelOptions, ClientNetworkData, NetworkDataError, ServerNetworkData,
40-
};
41-
pub use self::security_data::{
42-
ClientSecurityData, EncryptionLevel, EncryptionMethod, SecurityDataError, ServerSecurityData,
43-
};
33+
pub use self::network_data::{ChannelDef, ChannelName, ChannelOptions, ClientNetworkData, ServerNetworkData};
34+
pub use self::security_data::{ClientSecurityData, EncryptionLevel, EncryptionMethod, ServerSecurityData};
4435

4536
macro_rules! user_header_try {
4637
($e:expr) => {
@@ -355,94 +346,3 @@ impl UserDataHeader {
355346
Ok((block_type, src.read_slice(len)))
356347
}
357348
}
358-
359-
#[derive(Debug)]
360-
pub enum GccError {
361-
IOError(io::Error),
362-
CoreError(CoreDataError),
363-
SecurityError(SecurityDataError),
364-
NetworkError(NetworkDataError),
365-
ClusterError(ClusterDataError),
366-
InvalidGccType,
367-
InvalidConferenceCreateRequest(String),
368-
InvalidConferenceCreateResponse(String),
369-
RequiredClientDataBlockIsAbsent(ClientGccType),
370-
RequiredServerDataBlockIsAbsent(ServerGccType),
371-
Pdu(PduError),
372-
}
373-
374-
impl fmt::Display for GccError {
375-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
376-
match self {
377-
Self::IOError(_) => f.write_str("IO error"),
378-
Self::CoreError(_) => f.write_str("core data block error"),
379-
Self::SecurityError(_) => f.write_str("security data block error"),
380-
Self::NetworkError(_) => f.write_str("network data block error"),
381-
Self::ClusterError(_) => f.write_str("cluster data block error"),
382-
Self::InvalidGccType => f.write_str("invalid GCC block type"),
383-
Self::InvalidConferenceCreateRequest(s) => write!(f, "invalid conference create request: {s}"),
384-
Self::InvalidConferenceCreateResponse(s) => write!(f, "invalid Conference create response: {s}"),
385-
Self::RequiredClientDataBlockIsAbsent(ty) => {
386-
write!(f, "a server did not send the required GCC data block: {ty:?}")
387-
}
388-
Self::RequiredServerDataBlockIsAbsent(ty) => {
389-
write!(f, "a client did not send the required GCC data block: {ty:?}")
390-
}
391-
Self::Pdu(e) => write!(f, "PDU error: {e}"),
392-
}
393-
}
394-
}
395-
396-
impl core::error::Error for GccError {
397-
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
398-
match self {
399-
Self::IOError(e) => Some(e),
400-
Self::CoreError(e) => Some(e),
401-
Self::SecurityError(e) => Some(e),
402-
Self::NetworkError(e) => Some(e),
403-
Self::ClusterError(e) => Some(e),
404-
Self::InvalidGccType
405-
| Self::InvalidConferenceCreateRequest(_)
406-
| Self::InvalidConferenceCreateResponse(_)
407-
| Self::RequiredClientDataBlockIsAbsent(_)
408-
| Self::RequiredServerDataBlockIsAbsent(_)
409-
| Self::Pdu(_) => None,
410-
}
411-
}
412-
}
413-
414-
impl From<io::Error> for GccError {
415-
fn from(e: io::Error) -> Self {
416-
Self::IOError(e)
417-
}
418-
}
419-
420-
impl From<CoreDataError> for GccError {
421-
fn from(e: CoreDataError) -> Self {
422-
Self::CoreError(e)
423-
}
424-
}
425-
426-
impl From<SecurityDataError> for GccError {
427-
fn from(e: SecurityDataError) -> Self {
428-
Self::SecurityError(e)
429-
}
430-
}
431-
432-
impl From<NetworkDataError> for GccError {
433-
fn from(e: NetworkDataError) -> Self {
434-
Self::NetworkError(e)
435-
}
436-
}
437-
438-
impl From<ClusterDataError> for GccError {
439-
fn from(e: ClusterDataError) -> Self {
440-
Self::ClusterError(e)
441-
}
442-
}
443-
444-
impl From<PduError> for GccError {
445-
fn from(e: PduError) -> Self {
446-
Self::Pdu(e)
447-
}
448-
}

crates/ironrdp-pdu/src/gcc/network_data.rs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use core::fmt;
21
use std::borrow::Cow;
3-
use std::{io, str};
2+
use std::str;
43

54
use bitflags::bitflags;
65
use ironrdp_core::{
@@ -288,44 +287,3 @@ bitflags! {
288287
const REMOTE_CONTROL_PERSISTENT = 0x0010_0000;
289288
}
290289
}
291-
292-
#[derive(Debug)]
293-
pub enum NetworkDataError {
294-
IOError(io::Error),
295-
Utf8Error(str::Utf8Error),
296-
InvalidChannelOptions,
297-
InvalidChannelCount,
298-
}
299-
300-
impl fmt::Display for NetworkDataError {
301-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
302-
match self {
303-
Self::IOError(_) => f.write_str("IO error"),
304-
Self::Utf8Error(_) => f.write_str("UTF-8 error"),
305-
Self::InvalidChannelOptions => f.write_str("invalid channel options field"),
306-
Self::InvalidChannelCount => f.write_str("invalid channel count field"),
307-
}
308-
}
309-
}
310-
311-
impl core::error::Error for NetworkDataError {
312-
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
313-
match self {
314-
Self::IOError(e) => Some(e),
315-
Self::Utf8Error(e) => Some(e),
316-
Self::InvalidChannelOptions | Self::InvalidChannelCount => None,
317-
}
318-
}
319-
}
320-
321-
impl From<io::Error> for NetworkDataError {
322-
fn from(e: io::Error) -> Self {
323-
Self::IOError(e)
324-
}
325-
}
326-
327-
impl From<str::Utf8Error> for NetworkDataError {
328-
fn from(e: str::Utf8Error) -> Self {
329-
Self::Utf8Error(e)
330-
}
331-
}

crates/ironrdp-pdu/src/gcc/security_data.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use core::fmt;
2-
use std::io;
3-
41
use bitflags::bitflags;
52
use ironrdp_core::{
63
Decode, DecodeResult, Encode, EncodeResult, ReadCursor, WriteCursor, cast_length, ensure_fixed_part_size,
@@ -218,45 +215,3 @@ impl EncryptionLevel {
218215
self as u32
219216
}
220217
}
221-
222-
#[derive(Debug)]
223-
pub enum SecurityDataError {
224-
IOError(io::Error),
225-
InvalidEncryptionMethod,
226-
InvalidEncryptionLevel,
227-
InvalidServerRandomLen(u32),
228-
InvalidInput(String),
229-
InvalidServerCertificateLen(u32),
230-
}
231-
232-
impl fmt::Display for SecurityDataError {
233-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
234-
match self {
235-
Self::IOError(_) => f.write_str("IO error"),
236-
Self::InvalidEncryptionMethod => f.write_str("invalid encryption methods field"),
237-
Self::InvalidEncryptionLevel => f.write_str("invalid encryption level field"),
238-
Self::InvalidServerRandomLen(n) => write!(f, "invalid server random length field: {n}"),
239-
Self::InvalidInput(s) => write!(f, "invalid input: {s}"),
240-
Self::InvalidServerCertificateLen(n) => write!(f, "invalid server certificate length: {n}"),
241-
}
242-
}
243-
}
244-
245-
impl core::error::Error for SecurityDataError {
246-
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
247-
match self {
248-
Self::IOError(e) => Some(e),
249-
Self::InvalidEncryptionMethod
250-
| Self::InvalidEncryptionLevel
251-
| Self::InvalidServerRandomLen(_)
252-
| Self::InvalidInput(_)
253-
| Self::InvalidServerCertificateLen(_) => None,
254-
}
255-
}
256-
}
257-
258-
impl From<io::Error> for SecurityDataError {
259-
fn from(e: io::Error) -> Self {
260-
Self::IOError(e)
261-
}
262-
}

0 commit comments

Comments
 (0)