rosu_pp/any/
strains.rs

1use crate::{catch::CatchStrains, mania::ManiaStrains, osu::OsuStrains, taiko::TaikoStrains};
2
3/// The result of calculating the strains on a map.
4///
5/// Suitable to plot the difficulty of a map over time.
6#[derive(Clone, Debug, PartialEq)]
7pub enum Strains {
8    Osu(OsuStrains),
9    Taiko(TaikoStrains),
10    Catch(CatchStrains),
11    Mania(ManiaStrains),
12}
13
14impl Strains {
15    /// Time inbetween two strains in ms.
16    pub const fn section_len(&self) -> f64 {
17        match self {
18            Strains::Osu(_) => OsuStrains::SECTION_LEN,
19            Strains::Taiko(_) => TaikoStrains::SECTION_LEN,
20            Strains::Catch(_) => CatchStrains::SECTION_LEN,
21            Strains::Mania(_) => ManiaStrains::SECTION_LEN,
22        }
23    }
24}
25
26macro_rules! from_mode_strains {
27    ( $mode:ident: $strains:ident ) => {
28        impl From<$strains> for Strains {
29            fn from(strains: $strains) -> Self {
30                Self::$mode(strains)
31            }
32        }
33    };
34}
35
36from_mode_strains!(Osu: OsuStrains);
37from_mode_strains!(Taiko: TaikoStrains);
38from_mode_strains!(Catch: CatchStrains);
39from_mode_strains!(Mania: ManiaStrains);