Skip to main content

radio_cli/engine/
status.rs

1#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
2pub(super) enum SourceKind {
3    #[default]
4    Catalog,
5    Ephemeral,
6    DirectPodcast,
7    Local,
8    Episode,
9}
10
11pub(super) struct PlaybackTarget<'a> {
12    pub generation: u64,
13    pub url: &'a str,
14    pub source_kind: SourceKind,
15}
16
17#[derive(Debug, Clone, Default, PartialEq, Eq)]
18pub enum PlaybackState {
19    #[default]
20    Idle,
21    Connecting,
22    Reconnecting {
23        attempt: usize,
24    },
25    Playing,
26    Paused,
27    Failed {
28        reason: String,
29    },
30}
31impl PlaybackState {
32    pub fn label(&self) -> &'static str {
33        match self {
34            Self::Idle => crate::t!("state_playback_idle"),
35            Self::Connecting => crate::t!("state_playback_connecting"),
36            Self::Reconnecting { .. } => crate::t!("state_playback_reconnecting"),
37            Self::Playing => crate::t!("state_playback_playing"),
38            Self::Paused => crate::t!("state_playback_paused"),
39            Self::Failed { .. } => crate::t!("state_playback_failed"),
40        }
41    }
42}
43
44#[derive(Debug, Clone, Default, PartialEq, Eq)]
45pub enum RecordingState {
46    #[default]
47    Idle,
48    Probing,
49    Recording,
50    Finalizing,
51    Done,
52    Failed {
53        reason: String,
54    },
55}
56impl RecordingState {
57    pub fn label(&self) -> &'static str {
58        match self {
59            Self::Idle => crate::t!("state_recording_idle"),
60            Self::Probing => crate::t!("state_recording_probing"),
61            Self::Recording => crate::t!("state_recording_recording"),
62            Self::Finalizing => crate::t!("state_recording_finalizing"),
63            Self::Done => crate::t!("state_recording_done"),
64            Self::Failed { .. } => crate::t!("state_recording_failed"),
65        }
66    }
67}