refactor: mark public enums as non-exhaustive to improve API stability
Apply the #[non-exhaustive] attribute to ClientError and WarningKind to prevent breaking changes when adding new variants. Handle the catch-all case in the CLI formatter.
This commit is contained in:
3 files changed
+3
No files matched your search
@@ -831,6 +831,7 @@ fn warning_kind(kind: WarningKind) -> &'static str {
|
|||||||
WarningKind::MalformedOrUnrelatedPacket => "malformed_or_unrelated_packet",
|
WarningKind::MalformedOrUnrelatedPacket => "malformed_or_unrelated_packet",
|
||||||
WarningKind::WrongToken => "wrong_token",
|
WarningKind::WrongToken => "wrong_token",
|
||||||
WarningKind::UntrackedReply => "untracked_reply",
|
WarningKind::UntrackedReply => "untracked_reply",
|
||||||
|
_ => "unknown",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{io, time::Duration};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum ClientError {
|
pub enum ClientError {
|
||||||
#[error("failed to resolve server address {addr:?}")]
|
#[error("failed to resolve server address {addr:?}")]
|
||||||
Resolve { addr: String },
|
Resolve { addr: String },
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ pub enum ClientEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum WarningKind {
|
pub enum WarningKind {
|
||||||
MalformedOrUnrelatedPacket,
|
MalformedOrUnrelatedPacket,
|
||||||
WrongToken,
|
WrongToken,
|
||||||
|
|||||||
Reference in new issue
Block a user