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
//! Intermission entity and business logic
use serde_derive::{Deserialize, Serialize};
#[derive(
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash, Default, displaydoc::Display,
)]
#[serde(rename_all = "snake_case")]
pub enum IntermissionAction {
/// Extend the current intermission
#[default]
Extend,
/// Start a new intermission
New,
}
impl From<bool> for IntermissionAction {
fn from(new: bool) -> Self {
if new {
Self::New
} else {
Self::Extend
}
}
}
impl IntermissionAction {
/// Returns `true` if the intermission action is [`Extend`].
///
/// [`Extend`]: IntermissionAction::Extend
#[must_use]
pub const fn is_extend(&self) -> bool {
matches!(self, Self::Extend)
}
/// Returns `true` if the intermission action is [`New`].
///
/// [`New`]: IntermissionAction::New
#[must_use]
pub const fn is_new(&self) -> bool {
matches!(self, Self::New)
}
}