rosu 0.1.1

A wrapper for the osu! API.
Documentation
[![crates.io](https://img.shields.io/crates/v/rosu.svg?style=flat-square)](https://crates.io/crates/rosu) [![Released API docs](https://docs.rs/rosu/badge.svg)](https://docs.rs/rosu)

# rosu


rosu is a wrapper of the [osu!api](https://github.com/ppy/osu-api/wiki) written in rust.

The wrapper provides access to osu!'s beatmap, user, score, user-best, user-recent, and match endpoints with the help of the request structs `BeatmapRequest`, `UserRequest`, `ScoreRequest`, `BestRequest`, `RecentRequest`, and `MatchRequest`, respectively.
Create those request structs, add desired attributes, and then use their `queue` method to send the request and retrieve the parsed data.

The clients internal ratelimiter limits the amount of requests to the api to about 10 requests per second.

### Example

```rust
use chrono::{offset::TimeZone, DateTime, Utc};
use rosu::{
    backend::{BeatmapRequest, BestRequest, MatchRequest, UserRequest},
    models::*,
    Osu, OsuError,
};

#[tokio::main]

async fn main() -> Result<(), OsuError> {
    // Initialize the client
    let osu = Osu::new("osu_api_key");

    // --- Retrieving top scores ---

    // Accumulate all important arguments for the request
    let request = BestRequest::with_username("Badewanne3")
        .mode(GameMode::MNA)
        .limit(4);
    // Asynchronously send the request through the osu client
    let mut scores: Vec<Score> = request.queue(&osu).await?;
    match scores.pop() {
        Some(score) => {
            // Retrieve user of the score
            let user = score.get_user(&osu, GameMode::STD).await?;
            // ...
        }
        None => println!("No top scores found"),
    }

    // --- Retrieving beatmaps ---

    let since_date: DateTime<Utc> = Utc
        .datetime_from_str("2018-11-13 23:01:28", "%Y-%m-%d %H:%M:%S")
        .unwrap();
    let request = BeatmapRequest::new()
        .mode(GameMode::MNA)
        .limit(3)
        .mods(&GameMods::new(vec![GameMod::Key4, GameMod::Hidden]))
        .since(since_date)
        .mapset_id(945496);
    let mut maps: Vec<Beatmap> = request.queue(&osu).await?;
    if let Some(map) = maps.pop() {
        let leaderboard: Vec<Score> = map.get_global_leaderboard(&osu, 13).await?;
        // ...
    }

    // --- Retrieving user ---

    let user = UserRequest::with_username("Badewanne3")
        .queue_single(&osu)
        .await?;
    // ...

    // --- Retrieving match ---

    let osu_match = MatchRequest::with_match_id(58494587)
        .queue_single(&osu)
        .await?;

    // ...

    Ok(())
}

```