Skip to content

Commit 9062771

Browse files
tclemCopilot
andcommitted
Rename ConnectionState::Errored to ConnectionState::Error
Per follow-up on stephentoub's review of PR #1164: prefer renaming the variant to drop the `#[serde(rename = "error")]` attribute. The variant is unused outside types.rs (the Client transitions Disconnected / Connecting / Connected today; Error is reserved for future use), so renaming has no consumer impact and produces a cleaner enum surface. `ConnectionState::Error` does not collide with anything in scope: `types.rs` does not import `crate::Error` (it uses fully-qualified `crate::Error` at use sites) and `std::error::Error` is unimported. The variant lives inside a typed enum, so no shadowing concern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3109b77 commit 9062771

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

rust/src/types.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::transforms::SystemMessageTransform;
2727
/// from `Connecting` → `Connected` during construction, transitions to
2828
/// `Disconnected` after [`Client::stop`](crate::Client::stop) or
2929
/// [`Client::force_stop`](crate::Client::force_stop), and lands in
30-
/// `Errored` if startup fails or the underlying transport tears down
30+
/// `Error` if startup fails or the underlying transport tears down
3131
/// unexpectedly.
3232
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
3333
#[serde(rename_all = "lowercase")]
@@ -39,8 +39,7 @@ pub enum ConnectionState {
3939
/// The client is connected and ready to handle RPC traffic.
4040
Connected,
4141
/// Startup failed or the connection encountered an unrecoverable error.
42-
#[serde(rename = "error")]
43-
Errored,
42+
Error,
4443
}
4544

4645
/// Type of [`SessionLifecycleEvent`] received via [`Client::subscribe_lifecycle`](crate::Client::subscribe_lifecycle).
@@ -2208,11 +2207,11 @@ mod tests {
22082207
};
22092208

22102209
#[test]
2211-
fn connection_state_errored_serializes_as_error_to_match_go() {
2212-
let json = serde_json::to_string(&ConnectionState::Errored).unwrap();
2210+
fn connection_state_error_serializes_to_match_go() {
2211+
let json = serde_json::to_string(&ConnectionState::Error).unwrap();
22132212
assert_eq!(json, "\"error\"");
22142213
let parsed: ConnectionState = serde_json::from_str("\"error\"").unwrap();
2215-
assert_eq!(parsed, ConnectionState::Errored);
2214+
assert_eq!(parsed, ConnectionState::Error);
22162215
}
22172216

22182217
#[test]

0 commit comments

Comments
 (0)