refactor(mstsgu): derive Display and Error for GwErrorKind via thiserror#1258
Open
Greg Lamberson (glamberson) wants to merge 1 commit into
Open
Conversation
Refs Devolutions#1257 (proof-of-concept for the broader thiserror migration). Replace the hand-written `impl Display for GwErrorKind` and `impl core::error::Error for GwErrorKind` blocks with `#[derive(thiserror::Error)]` and per-variant `#[error("...")]` attributes. GwErrorKind has 7 variants and is the smallest hand-written *ErrorKind enum in the workspace, so it is suitable as the proof-of-concept that: - Display output is byte-identical (verified via cargo expand: both implementations call `formatter.write_str("literal")` with the same string for each variant). - The workspace `thiserror` dependency lands cleanly. ironrdp-pdu already pins thiserror = "2.0" for some internal types; this PR adds the same direct dep to ironrdp-mstsgu following Devolutions' stated preference for per-crate (non-workspace.dependencies) entries. - MSRV is unaffected (thiserror 2.0 needs Rust 1.61, IronRDP MSRV is 1.89). Public API impact: none. The `pub type Error = ironrdp_error::Error<GwErrorKind>` alias and the `GwErrorExt::custom()` helper are unchanged. Consumers of `Error` see no source-level break. Verification: - cargo xtask check fmt: clean - cargo xtask check lints: clean - cargo xtask check locks: Cargo.lock updated and included in this commit - cargo xtask check typos: clean - cargo xtask check tests: clean - cargo expand inspection: Display impl byte-identical to prior hand-written version for all 7 variants
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1257.
First proof-of-concept for the broader
thiserrormigration proposed in #1257.GwErrorKindis the smallest hand-written*ErrorKindenum in the workspace at 7 variants, so it is suitable for verifying that the migration is byte-identity-preserving and that the workspacethiserrordep lands cleanly.What this changes
Replaces the hand-written
impl Display for GwErrorKindandimpl core::error::Error for GwErrorKindblocks with#[derive(thiserror::Error)]and per-variant#[error("...")]attributes. Addsthiserror = "2"tocrates/ironrdp-mstsgu/Cargo.tomlas a direct dependency, following the same pattern thatironrdp-pdualready uses for its internalthiserrortypes.Public API impact
None. The
pub type Error = ironrdp_error::Error<GwErrorKind>alias and theGwErrorExt::custom()helper are unchanged. Consumers see no source-level break.Display byte-identity verification
Verified via
cargo expand. Both the prior hand-written implementation and thethiserror-derived implementation callformatter.write_str("literal")with the same string for each of the 7 variants:InvalidGwTarget"invalid GW Target"Connect"connection error"PacketEof"PacketEOF"UnsupportedFeature"unsupported feature"Custom"custom"Encode"encode"Decode"decode"Verification
cargo xtask check fmt: cleancargo xtask check lints: cleancargo xtask check locks: cleancargo xtask check typos: cleancargo xtask check tests: cleanMSRV
Unaffected.
thiserror2.0 requires Rust 1.61, well below IronRDP's MSRV of 1.89.