Crate osu [] [src]

osu.rs

Unofficial Rust crate for the osu! API.

[Documentation][docs]

Installation

Add the following dependency to your Cargo.toml:

osu = "0.2"

And include it in your project:

extern crate osu;

Examples

Using hyper with the hyper-tls HTTPS connector, retrieve the start time of a match by ID:

extern crate futures;
extern crate hyper;
extern crate hyper_tls;
extern crate osu;
extern crate tokio_core;

use futures::Future;
use hyper::client::{Client, HttpConnector};
use hyper_tls::HttpsConnector;
use osu::bridge::hyper::OsuHyperRequester;
use std::error::Error;
use std::env;
use tokio_core::reactor::Core;

fn try_main() -> Result<(), Box<Error>> {
    let mut core = Core::new()?;
    let client = Client::configure()
        .connector(HttpsConnector::new(4, &core.handle())?)
        .build(&core.handle());
    let key = env::var("OSU_KEY")?;

    let done = client.get_match(&key, 71641).map(|found| {
        println!("Match start time: {}", found.start_time);

        ()
    }).map_err(|_| ());

    core.run(done).expect("Error running core");

    Ok(())
}

fn main() {
    try_main().unwrap();
}

Using reqwest, retrieve a match's start time by ID:

extern crate osu;
extern crate reqwest;

use osu::bridge::reqwest::OsuReqwestRequester;
use reqwest::Client;
use std::error::Error;

fn try_main() -> Result<(), Box<Error>> {
    let key = env::var("OSU_KEY")?;
    let client = Client::new();
    let found = client.get_match(&key, 71641)?;

    println!("Match start time: {}", found.start_time);

    Ok(())
}

fn main() {
    try_main().unwrap();
}

Reexports

pub use error::Error;
pub use error::Result;

Modules

bridge

Bridged implementation support for various HTTP clients.

builder

A set of builders for use with some request functions that have multiple optional parameters.

error

The error and result types returned by the library.

Structs

Beatmap
Game
GameScore
Match
MatchScore
Mods
Performance
RecentPlay
User
UserEvent

Enums

Approval
Genre
GetBeatmapUser

Information for retrieving a user.

Language
PlayMode
ScoringType
TeamType

Constants

API_URL

The base URL for all requests to osu!'s API.