Skip to content

Commit 2d66079

Browse files
committed
refactor: prevent future RpcError variants from breaking downstream matches
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.
1 parent 4e95938 commit 2d66079

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4949
(`current.saturating_add(chunk_size - 1).min(end)` per chunk,
5050
advancing via `to_block.checked_add(1)` so the loop breaks when
5151
the chunk ends at `u64::MAX`). Closes #36.
52+
- Exhaustive `match` arms over `RpcError` written in a downstream crate
53+
must now include a wildcard (`_ => ...`) fallback. The enum is now
54+
marked `#[non_exhaustive]`, matching the discipline already in place
55+
on the crate's other public provider-surface types (`RpcConfig`,
56+
`ChainEndpoint`) — so future operational variants (e.g. the
57+
`ConflictingRateLimit` variant added in this release, or further
58+
per-endpoint health/quota signals) can be added without forcing
59+
another breaking change at this boundary. Consumers that already
60+
default-handle unknown variants are unaffected; consumers that match
61+
only the variants they care about and ignore the rest gain stability
62+
across future variant additions. Closes #62.
5263

5364
### Added
5465

src/errors/rpc.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,18 @@ use alloy_transport::TransportError;
8080
/// };
8181
/// println!("Error: {}", error);
8282
/// ```
83+
///
84+
/// # Stability
85+
///
86+
/// This enum is marked `#[non_exhaustive]`. New variants may be added in
87+
/// future releases without a major-version bump, so downstream `match`
88+
/// arms over `RpcError` from another crate must include a wildcard
89+
/// (`_ => ...`) arm. This mirrors the discipline already applied to the
90+
/// crate's other public configuration types (`RpcConfig`,
91+
/// `ChainEndpoint`) so that adding a new operational error variant does
92+
/// not force every consumer to recompile.
8393
#[derive(Debug, thiserror::Error)]
94+
#[non_exhaustive]
8495
pub enum RpcError {
8596
/// Failed to fetch logs from the blockchain.
8697
///

0 commit comments

Comments
 (0)