kestrel_protocol_timer/
error.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum TimerError {
6 InvalidSlotCount {
8 slot_count: usize,
9 reason: &'static str,
10 },
11
12 ChannelClosed,
14}
15
16impl fmt::Display for TimerError {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self {
19 TimerError::InvalidSlotCount { slot_count, reason } => {
20 write!(f, "无效的槽位数量 {}: {}", slot_count, reason)
21 }
22 TimerError::ChannelClosed => {
23 write!(f, "内部通信通道已关闭")
24 }
25 }
26 }
27}
28
29impl std::error::Error for TimerError {}
30