1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Queue mode definitions.
/// Queue mode
///
/// # Examples
///
/// ```
/// use celers_kombu::QueueMode;
///
/// let fifo = QueueMode::Fifo;
/// assert!(fifo.is_fifo());
/// assert!(!fifo.is_priority());
/// assert_eq!(fifo.to_string(), "FIFO");
///
/// let priority = QueueMode::Priority;
/// assert!(priority.is_priority());
/// assert!(!priority.is_fifo());
/// assert_eq!(priority.to_string(), "Priority");
/// ```
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QueueMode {
/// First-In-First-Out
Fifo,
/// Priority-based
Priority,
}
impl QueueMode {
/// Check if this is FIFO mode
pub fn is_fifo(&self) -> bool {
matches!(self, QueueMode::Fifo)
}
/// Check if this is Priority mode
pub fn is_priority(&self) -> bool {
matches!(self, QueueMode::Priority)
}
}
impl std::fmt::Display for QueueMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
QueueMode::Fifo => write!(f, "FIFO"),
QueueMode::Priority => write!(f, "Priority"),
}
}
}