rosu_map/section/general/
mod.rs1use std::str::FromStr;
2
3pub use self::decode::{General, GeneralKey, GeneralState, ParseGeneralError};
4
5pub(crate) mod decode; #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
9pub enum GameMode {
10 #[default]
11 Osu,
12 Taiko,
13 Catch,
14 Mania,
15}
16
17thiserror! {
18 #[error("invalid game mode")]
19 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
21 pub struct ParseGameModeError;
22}
23
24impl FromStr for GameMode {
25 type Err = ParseGameModeError;
26
27 fn from_str(mode: &str) -> Result<Self, Self::Err> {
28 match mode {
29 "0" => Ok(Self::Osu),
30 "1" => Ok(Self::Taiko),
31 "2" => Ok(Self::Catch),
32 "3" => Ok(Self::Mania),
33 _ => Err(ParseGameModeError),
34 }
35 }
36}
37
38impl From<u8> for GameMode {
39 fn from(mode: u8) -> Self {
40 match mode {
41 0 => Self::Osu,
42 1 => Self::Taiko,
43 2 => Self::Catch,
44 3 => Self::Mania,
45 _ => Self::Osu,
46 }
47 }
48}
49
50#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
54pub enum CountdownType {
55 #[default]
56 None,
57 Normal,
58 HalfSpeed,
59 DoubleSpeed,
60}
61
62impl FromStr for CountdownType {
63 type Err = ParseCountdownTypeError;
64
65 fn from_str(s: &str) -> Result<Self, Self::Err> {
66 match s {
67 "0" | "None" => Ok(Self::None),
68 "1" | "Normal" => Ok(Self::Normal),
69 "2" | "Half speed" => Ok(Self::HalfSpeed),
70 "3" | "Double speed" => Ok(Self::DoubleSpeed),
71 _ => Err(ParseCountdownTypeError),
72 }
73 }
74}
75
76thiserror! {
77 #[error("invalid countdown type")]
78 #[derive(Debug)]
80 pub struct ParseCountdownTypeError;
81}