1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
6pub enum CloneStreamError {
7 MaxClonesExceeded {
9 max_allowed: usize,
10 current_count: usize,
11 },
12 InvalidCloneId { clone_id: usize },
14 CloneAlreadyActive { clone_id: usize },
16}
17
18impl fmt::Display for CloneStreamError {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 match self {
21 Self::MaxClonesExceeded {
22 max_allowed,
23 current_count,
24 } => write!(
25 f,
26 "Maximum number of clones exceeded: {current_count} >= {max_allowed}"
27 ),
28 Self::InvalidCloneId { clone_id } => {
29 write!(f, "Invalid clone ID: {clone_id}")
30 }
31 Self::CloneAlreadyActive { clone_id } => {
32 write!(f, "Clone {clone_id} is already active")
33 }
34 }
35 }
36}
37
38impl std::error::Error for CloneStreamError {}
39
40pub type Result<T> = std::result::Result<T, CloneStreamError>;