#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum ServerCancellationReason {
Graceful,
Dropped,
}
impl ServerCancellationReason {
pub(crate) const fn label(self) -> &'static str {
match self {
Self::Graceful => "graceful",
Self::Dropped => "dropped",
}
}
}
#[cfg(feature = "metrics")]
impl ServerCancellationReason {
pub(crate) const fn as_str(self) -> &'static str { self.label() }
}
#[cfg(test)]
mod tests {
use super::ServerCancellationReason;
#[test]
fn cancellation_reason_labels_match_bounded_vocabulary() {
assert_eq!(ServerCancellationReason::Graceful.label(), "graceful");
assert_eq!(ServerCancellationReason::Dropped.label(), "dropped");
}
}