rosu_memory_lib/reader/beatmap/
mod.rs

1pub mod common;
2pub mod stable;
3
4use crate::reader::beatmap::common::BeatmapInfo;
5use crate::reader::beatmap::common::BeatmapStarRating;
6use crate::reader::beatmap::common::BeatmapStats;
7use crate::reader::beatmap::common::BeatmapStatus;
8use crate::reader::common::GameMode;
9use crate::reader::common::OsuType;
10use crate::reader::structs::State;
11use crate::Error;
12use rosu_mem::process::Process;
13
14pub struct BeatmapReader<'a> {
15    pub process: &'a Process,
16    pub state: &'a mut State,
17    pub osu_type: OsuType,
18}
19
20impl<'a> BeatmapReader<'a> {
21    pub fn new(p: &'a Process, state: &'a mut State, osu_type: OsuType) -> Result<Self, Error> {
22        Ok(Self {
23            process: p,
24            state,
25            osu_type,
26        })
27    }
28
29    pub fn get_beatmap_info(&mut self) -> Result<BeatmapInfo, Error> {
30        match self.osu_type {
31            OsuType::Stable => stable::memory::get_beatmap_info(self.process, self.state),
32            _ => Err(Error::Unsupported(
33                "Unsupported osu type for now".to_string(),
34            )),
35        }
36    }
37
38    pub fn get_beatmap_path(&mut self) -> Result<String, Error> {
39        match self.osu_type {
40            OsuType::Stable => stable::file::get_beatmap_path(self.process, self.state),
41            _ => Err(Error::Unsupported(
42                "Unsupported osu type for now".to_string(),
43            )),
44        }
45    }
46
47    pub fn get_audio_path(&mut self) -> Result<String, Error> {
48        match self.osu_type {
49            OsuType::Stable => stable::file::get_audio_path(self.process, self.state),
50            _ => Err(Error::Unsupported(
51                "Unsupported osu type for now".to_string(),
52            )),
53        }
54    }
55
56    pub fn get_beatmap_md5(&mut self) -> Result<String, Error> {
57        match self.osu_type {
58            OsuType::Stable => stable::memory::get_beatmap_md5(self.process, self.state),
59            _ => Err(Error::Unsupported(
60                "Unsupported osu type for now".to_string(),
61            )),
62        }
63    }
64
65    pub fn get_beatmap_id(&mut self) -> Result<i32, Error> {
66        match self.osu_type {
67            OsuType::Stable => stable::memory::get_beatmap_id(self.process, self.state),
68            _ => Err(Error::Unsupported(
69                "Unsupported osu type for now".to_string(),
70            )),
71        }
72    }
73
74    pub fn get_beatmap_set_id(&mut self) -> Result<i32, Error> {
75        match self.osu_type {
76            OsuType::Stable => stable::memory::get_beatmap_set_id(self.process, self.state),
77            _ => Err(Error::Unsupported(
78                "Unsupported osu type for now".to_string(),
79            )),
80        }
81    }
82
83    pub fn get_beatmap_mode(&mut self) -> Result<GameMode, Error> {
84        match self.osu_type {
85            OsuType::Stable => stable::memory::get_beatmap_mode(self.process, self.state),
86            _ => Err(Error::Unsupported(
87                "Unsupported osu type for now".to_string(),
88            )),
89        }
90    }
91
92    pub fn get_beatmap_tags(&mut self) -> Result<String, Error> {
93        match self.osu_type {
94            OsuType::Stable => stable::memory::get_beatmap_tags(self.process, self.state),
95            _ => Err(Error::Unsupported(
96                "Unsupported osu type for now".to_string(),
97            )),
98        }
99    }
100
101    pub fn get_beatmap_length(&mut self) -> Result<i32, Error> {
102        match self.osu_type {
103            OsuType::Stable => stable::memory::get_beatmap_length(self.process, self.state),
104            _ => Err(Error::Unsupported(
105                "Unsupported osu type for now".to_string(),
106            )),
107        }
108    }
109
110    pub fn get_beatmap_drain_time(&mut self) -> Result<i32, Error> {
111        match self.osu_type {
112            OsuType::Stable => stable::memory::get_beatmap_drain_time(self.process, self.state),
113            _ => Err(Error::Unsupported(
114                "Unsupported osu type for now".to_string(),
115            )),
116        }
117    }
118
119    pub fn get_beatmap_status(&mut self) -> Result<BeatmapStatus, Error> {
120        match self.osu_type {
121            OsuType::Stable => stable::memory::get_beatmap_status(self.process, self.state),
122            _ => Err(Error::Unsupported(
123                "Unsupported osu type for now".to_string(),
124            )),
125        }
126    }
127
128    pub fn get_author(&mut self) -> Result<String, Error> {
129        match self.osu_type {
130            OsuType::Stable => stable::memory::get_author(self.process, self.state),
131            _ => Err(Error::Unsupported(
132                "Unsupported osu type for now".to_string(),
133            )),
134        }
135    }
136
137    pub fn get_creator(&mut self) -> Result<String, Error> {
138        match self.osu_type {
139            OsuType::Stable => stable::memory::get_creator(self.process, self.state),
140            _ => Err(Error::Unsupported(
141                "Unsupported osu type for now".to_string(),
142            )),
143        }
144    }
145
146    pub fn get_title_romanized(&mut self) -> Result<String, Error> {
147        match self.osu_type {
148            OsuType::Stable => stable::memory::get_title_romanized(self.process, self.state),
149            _ => Err(Error::Unsupported(
150                "Unsupported osu type for now".to_string(),
151            )),
152        }
153    }
154
155    pub fn get_title_original(&mut self) -> Result<String, Error> {
156        match self.osu_type {
157            OsuType::Stable => stable::memory::get_title_original(self.process, self.state),
158            _ => Err(Error::Unsupported(
159                "Unsupported osu type for now".to_string(),
160            )),
161        }
162    }
163
164    pub fn get_difficulty(&mut self) -> Result<String, Error> {
165        match self.osu_type {
166            OsuType::Stable => stable::memory::get_difficulty(self.process, self.state),
167            _ => Err(Error::Unsupported(
168                "Unsupported osu type for now".to_string(),
169            )),
170        }
171    }
172
173    pub fn get_beatmap_od(&mut self) -> Result<f32, Error> {
174        match self.osu_type {
175            OsuType::Stable => stable::memory::get_beatmap_od(self.process, self.state),
176            _ => Err(Error::Unsupported(
177                "Unsupported osu type for now".to_string(),
178            )),
179        }
180    }
181
182    pub fn get_beatmap_ar(&mut self) -> Result<f32, Error> {
183        match self.osu_type {
184            OsuType::Stable => stable::memory::get_beatmap_ar(self.process, self.state),
185            _ => Err(Error::Unsupported(
186                "Unsupported osu type for now".to_string(),
187            )),
188        }
189    }
190
191    pub fn get_beatmap_cs(&mut self) -> Result<f32, Error> {
192        match self.osu_type {
193            OsuType::Stable => stable::memory::get_beatmap_cs(self.process, self.state),
194            _ => Err(Error::Unsupported(
195                "Unsupported osu type for now".to_string(),
196            )),
197        }
198    }
199
200    pub fn get_beatmap_hp(&mut self) -> Result<f32, Error> {
201        match self.osu_type {
202            OsuType::Stable => stable::memory::get_beatmap_hp(self.process, self.state),
203            _ => Err(Error::Unsupported(
204                "Unsupported osu type for now".to_string(),
205            )),
206        }
207    }
208
209    pub fn get_beatmap_object_count(&mut self) -> Result<u32, Error> {
210        match self.osu_type {
211            OsuType::Stable => stable::memory::get_beatmap_object_count(self.process, self.state),
212            _ => Err(Error::Unsupported(
213                "Unsupported osu type for now".to_string(),
214            )),
215        }
216    }
217
218    pub fn get_beatmap_slider_count(&mut self) -> Result<i32, Error> {
219        match self.osu_type {
220            OsuType::Stable => stable::memory::get_beatmap_slider_count(self.process, self.state),
221            _ => Err(Error::Unsupported(
222                "Unsupported osu type for now".to_string(),
223            )),
224        }
225    }
226
227    pub fn get_beatmap_star_rating(&mut self) -> Result<BeatmapStarRating, Error> {
228        match self.osu_type {
229            OsuType::Stable => stable::file::get_beatmap_star_rating(self.process, self.state),
230            _ => Err(Error::Unsupported(
231                "Unsupported osu type for now".to_string(),
232            )),
233        }
234    }
235
236    pub fn get_beatmap_stats(&mut self) -> Result<BeatmapStats, Error> {
237        match self.osu_type {
238            OsuType::Stable => stable::memory::get_beatmap_stats(self.process, self.state),
239            _ => Err(Error::Unsupported(
240                "Unsupported osu type for now".to_string(),
241            )),
242        }
243    }
244}