rosu_memory_lib/reader/user/
mod.rs1pub mod common;
2pub mod stable;
3use crate::reader::common::OsuType;
4use crate::reader::structs::State;
5use crate::reader::user::common::UserInfo;
6use crate::Error;
7use rosu_mem::process::Process;
8
9pub struct UserReader<'a> {
10 pub process: &'a Process,
11 pub state: &'a mut State,
12 pub osu_type: OsuType,
13}
14
15impl<'a> UserReader<'a> {
16 pub fn new(p: &'a Process, state: &'a mut State, osu_type: OsuType) -> Self {
17 Self {
18 process: p,
19 state,
20 osu_type,
21 }
22 }
23
24 pub fn get_user_info(&mut self) -> Result<UserInfo, Error> {
25 match self.osu_type {
26 OsuType::Stable => stable::memory::get_user_info(self.process, self.state),
27 _ => Err(Error::Unsupported(
28 "Unsupported osu type for now".to_string(),
29 )),
30 }
31 }
32
33 pub fn get_user_id(&mut self) -> Result<i32, Error> {
34 match self.osu_type {
35 OsuType::Stable => stable::memory::get_user_id(self.process, self.state),
36 _ => Err(Error::Unsupported(
37 "Unsupported osu type for now".to_string(),
38 )),
39 }
40 }
41
42 pub fn get_user_bancho_status(&mut self) -> Result<i32, Error> {
43 match self.osu_type {
44 OsuType::Stable => stable::memory::get_user_bancho_status(self.process, self.state),
45 _ => Err(Error::Unsupported(
46 "Unsupported osu type for now".to_string(),
47 )),
48 }
49 }
50
51 pub fn get_user_country_code(&mut self) -> Result<i32, Error> {
52 match self.osu_type {
53 OsuType::Stable => stable::memory::get_user_country_code(self.process, self.state),
54 _ => Err(Error::Unsupported(
55 "Unsupported osu type for now".to_string(),
56 )),
57 }
58 }
59
60 pub fn get_user_username(&mut self) -> Result<String, Error> {
61 match self.osu_type {
62 OsuType::Stable => stable::memory::get_user_username(self.process, self.state),
63 _ => Err(Error::Unsupported(
64 "Unsupported osu type for now".to_string(),
65 )),
66 }
67 }
68
69 pub fn get_user_pp(&mut self) -> Result<i32, Error> {
70 match self.osu_type {
71 OsuType::Stable => stable::memory::get_user_pp(self.process, self.state),
72 _ => Err(Error::Unsupported(
73 "Unsupported osu type for now".to_string(),
74 )),
75 }
76 }
77
78 pub fn get_user_rankedscore(&mut self) -> Result<i64, Error> {
79 match self.osu_type {
80 OsuType::Stable => stable::memory::get_user_rankedscore(self.process, self.state),
81 _ => Err(Error::Unsupported(
82 "Unsupported osu type for now".to_string(),
83 )),
84 }
85 }
86
87 pub fn get_user_level(&mut self) -> Result<f32, Error> {
88 match self.osu_type {
89 OsuType::Stable => stable::memory::get_user_level(self.process, self.state),
90 _ => Err(Error::Unsupported(
91 "Unsupported osu type for now".to_string(),
92 )),
93 }
94 }
95
96 pub fn get_user_playcount(&mut self) -> Result<i32, Error> {
97 match self.osu_type {
98 OsuType::Stable => stable::memory::get_user_playcount(self.process, self.state),
99 _ => Err(Error::Unsupported(
100 "Unsupported osu type for now".to_string(),
101 )),
102 }
103 }
104
105 pub fn get_user_rank(&mut self) -> Result<i32, Error> {
106 match self.osu_type {
107 OsuType::Stable => stable::memory::get_user_rank(self.process, self.state),
108 _ => Err(Error::Unsupported(
109 "Unsupported osu type for now".to_string(),
110 )),
111 }
112 }
113
114 pub fn get_user_playmode(&mut self) -> Result<i32, Error> {
115 match self.osu_type {
116 OsuType::Stable => stable::memory::get_user_playmode(self.process, self.state),
117 _ => Err(Error::Unsupported(
118 "Unsupported osu type for now".to_string(),
119 )),
120 }
121 }
122
123 pub fn get_user_accuracy(&mut self) -> Result<f64, Error> {
124 match self.osu_type {
125 OsuType::Stable => stable::memory::get_user_accuracy(self.process, self.state),
126 _ => Err(Error::Unsupported(
127 "Unsupported osu type for now".to_string(),
128 )),
129 }
130 }
131}