hypixel 0.1.0

Rust wrapper for the Hypixel public API.
Documentation
//! Stores the errors from the Hypixel public API. This is re exported 
//! for extra clarity.
use std::fmt::{Display, Formatter};
use std::error::Error;
use std::result::Result;
use std::fmt;

/// These enumerates all errors that can be returned from the
/// Hypixel public API. 
#[derive(Debug)]
pub enum HypixelError {
    /// Error returned by Reqwest.
    Reqwest(reqwest::Error),
    /// Hypixel API returned an unsuccessfull response code.
    FailedResponse(u16, String),
    /// Serde could not deserialize JSON data properly.
    Json(serde_json ::Error)
}

impl Error for HypixelError {}

impl Display for HypixelError {
    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
        use HypixelError::*;
        match self {
            Reqwest(e) => write!(f, "Reqwest error: {}", e)?,
            FailedResponse(c, r) => write!(f, "Unexpected status code: {} reason: {}", c, r)?,
            Json(e) => write!(f, "Could not de-serialize JSON: {}", e)?,
        }
        Ok(())
    }
}