Function init_loop

Source
pub fn init_loop(sleep_duration: u64) -> Result<(State, Process)>
Examples found in repository?
examples/getig.rs (line 6)
5fn main() -> eyre::Result<()> {
6    let (mut state, process) = init_loop(500)?;
7    println!("Successfully initialized!");
8    loop {
9        match get_ig_time(&process, &mut state) {
10                Ok(ig_time) => println!("Current ig time: {ig_time:?}"),
11                Err(e) => println!("Error: {e:?}"),
12        }
13        std::thread::sleep(std::time::Duration::from_millis(1000));
14    }
15}
More examples
Hide additional examples
examples/beatmap1.rs (line 6)
5fn main() -> eyre::Result<()> {
6    let (mut state, process) = init_loop(500)?;
7    println!("Successfully initialized!");
8    loop {
9        match get_beatmap_info(&process, &mut state) {
10                Ok(beatmap_info) => println!("Current beatmap info: {beatmap_info:?}"),
11                Err(e) => println!("Error: {e:?}"),
12        }
13        std::thread::sleep(std::time::Duration::from_millis(1000));
14    }
15}
examples/beatmap2.rs (line 8)
7fn main() -> eyre::Result<()> {
8    let (mut state, process) = init_loop(500)?;
9    let mut beatmap_reader = BeatmapReader::new(&process, &mut state, OsuType::Stable)?;
10    loop {
11        match beatmap_reader.get_beatmap_info() {
12                Ok(beatmap_info) => println!("Current beatmap info: {beatmap_info:?}"),
13                Err(e) => println!("Error: {e:?}"),
14        }
15        std::thread::sleep(std::time::Duration::from_millis(1000));
16    }
17}
examples/pp.rs (line 118)
116fn main() -> Result<()> {
117    // Initialize connection to osu! process, checking every 500ms
118    let (mut state, process) = init_loop(500)?;
119    println!("Successfully connected to osu! process!");
120
121    // Initialize calculator state
122    let mut calc_state = CalculatorState::new();
123
124    // Main monitoring loop
125    loop {
126        if let Err(e) = process_game_state(&process, &mut state, &mut calc_state) {
127            eprintln!("Error during processing: {e}");
128        }
129
130        // Wait before next check to avoid excessive CPU usage
131        std::thread::sleep(Duration::from_millis(1000));
132    }
133}