rosu_memory_lib/reader/user/
mod.rs

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