refactor: prevent future RpcError variants from breaking downstream matches#63
Merged
Merged
Conversation
…atches Marks `RpcError` `#[non_exhaustive]` so adding a new operational variant no longer forces a major-version bump on consumers. Exhaustive matches over `RpcError` written in a downstream crate now need a wildcard (`_ => ...`) arm; in exchange, future variant additions (further per-endpoint health/quota signals, follow-ons to the `ConflictingRateLimit` variant added in this release, etc.) stop being breaking changes at this boundary. Aligns the discipline already in place on the peer public provider-surface types `RpcConfig` and `ChainEndpoint`. Closes #62.
Contributor
Author
Self-review passPre-commit
No blockers remaining. All three feature combos ( |
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.
Summary
Marks the public
RpcErrorenum#[non_exhaustive]so that futureoperational variants (further per-endpoint health/quota signals,
follow-ons to the
ConflictingRateLimitvariant added in thisrelease, etc.) can be added without forcing a major-version bump on
every downstream consumer. The cost is one-time: exhaustive matches
over
RpcErrorwritten in a downstream crate need a wildcard(
_ => ...) arm. Aligns the discipline already applied to the peerpublic provider-surface types
RpcConfigandChainEndpoint.Closes #62.
What's in the diff
src/errors/rpc.rs— adds#[non_exhaustive]to thepub enum RpcErrordeclaration plus a
# Stabilityrustdoc section explaining thecontract to downstream consumers.
CHANGELOG.md— new bullet under[Unreleased]/Breaking Changesspelling out the wildcard-arm requirement and the forward-compatibility
benefit, framed in operator-facing language and linking to the
asymmetry it resolves with the peer types.
Acceptance check (from #62)
#[non_exhaustive]added topub enum RpcError(src/errors/rpc.rs).[Unreleased]/Breaking Changes,noting the
_ => ...requirement.not spent as a standalone bump.
Test plan
cargo fmt --checkcleancargo clippy --all-targets --all-features -- -D warningscleancargo test— 97/97 pass (default features)cargo test --all-features— 97/97 passcargo test --no-default-features— 97/97 passRpcError: none (verified bygrep across
src/,tests/,examples/). The onlymatchon atype named
RpcErrorlives insrc/transport/retry.rs:363butbinds alloy's
alloy_json_rpc::RpcError, a name collision withour type.