|
1 | 1 | #![warn(clippy::pedantic)]
|
2 | 2 | #![allow(clippy::too_many_lines)]
|
3 | 3 |
|
4 |
| -use chrono::{DateTime, Utc}; |
5 |
| - |
6 | 4 | pub mod chart;
|
7 | 5 | pub mod log;
|
8 | 6 | pub mod service_worker;
|
9 | 7 |
|
10 |
| -#[allow(async_fn_in_trait)] |
11 |
| -pub trait SettingsRepository { |
12 |
| - async fn read_settings(&self) -> Result<Settings, String>; |
13 |
| - async fn write_settings(&self, settings: Settings) -> Result<(), String>; |
14 |
| -} |
15 |
| - |
16 |
| -#[allow(async_fn_in_trait)] |
17 |
| -pub trait OngoingTrainingSessionRepository { |
18 |
| - async fn read_ongoing_training_session(&self) |
19 |
| - -> Result<Option<OngoingTrainingSession>, String>; |
20 |
| - async fn write_ongoing_training_session( |
21 |
| - &self, |
22 |
| - ongoing_training_session: Option<OngoingTrainingSession>, |
23 |
| - ) -> Result<(), String>; |
24 |
| -} |
25 |
| - |
26 |
| -#[derive(serde::Serialize, serde::Deserialize, Clone)] |
27 |
| -#[allow(clippy::struct_excessive_bools)] |
28 |
| -pub struct Settings { |
29 |
| - pub beep_volume: u8, |
30 |
| - pub theme: Theme, |
31 |
| - pub automatic_metronome: bool, |
32 |
| - pub notifications: bool, |
33 |
| - pub show_rpe: bool, |
34 |
| - pub show_tut: bool, |
35 |
| -} |
36 |
| - |
37 |
| -impl Default for Settings { |
38 |
| - fn default() -> Self { |
39 |
| - Self { |
40 |
| - beep_volume: 80, |
41 |
| - theme: Theme::Light, |
42 |
| - automatic_metronome: false, |
43 |
| - notifications: false, |
44 |
| - show_rpe: true, |
45 |
| - show_tut: true, |
46 |
| - } |
47 |
| - } |
48 |
| -} |
49 |
| - |
50 |
| -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq)] |
51 |
| -pub enum Theme { |
52 |
| - System, |
53 |
| - Light, |
54 |
| - Dark, |
55 |
| -} |
56 |
| - |
57 |
| -#[derive(serde::Serialize, serde::Deserialize, Clone)] |
58 |
| -pub struct OngoingTrainingSession { |
59 |
| - pub training_session_id: u128, |
60 |
| - pub start_time: DateTime<Utc>, |
61 |
| - pub element_idx: usize, |
62 |
| - pub element_start_time: DateTime<Utc>, |
63 |
| - pub timer_state: TimerState, |
64 |
| -} |
65 |
| - |
66 |
| -impl OngoingTrainingSession { |
67 |
| - #[must_use] |
68 |
| - pub fn new(training_session_id: u128) -> Self { |
69 |
| - Self { |
70 |
| - training_session_id, |
71 |
| - start_time: Utc::now(), |
72 |
| - element_idx: 0, |
73 |
| - element_start_time: Utc::now(), |
74 |
| - timer_state: TimerState::Unset, |
75 |
| - } |
76 |
| - } |
77 |
| -} |
| 8 | +pub use ongoing_training_session::{ |
| 9 | + OngoingTrainingSession, OngoingTrainingSessionRepository, TimerState, |
| 10 | +}; |
| 11 | +pub use settings::{Settings, SettingsRepository, Theme}; |
78 | 12 |
|
79 |
| -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy)] |
80 |
| -pub enum TimerState { |
81 |
| - Unset, |
82 |
| - Active { target_time: DateTime<Utc> }, |
83 |
| - Paused { time: i64 }, |
84 |
| -} |
| 13 | +mod ongoing_training_session; |
| 14 | +mod settings; |
0 commit comments