dogehouse_api/lib.rs
1//! # Dogehouse-api
2//! This is a work-in-progress crate to interact with the dogehouse API.
3//! Note that the API's documentation isn't complete yet, and so is the API itself.
4//! This uses reqwest and serde-json. I don't know if libraries should use something different from
5//! reqwest. If so, please file an issue on GitHub.
6//! ## Current features:
7//! - Get a list of popular rooms
8//! - Get a list of upcoming rooms
9//! - Get a list of bots
10//! - Get basic statistics
11//! - Get individual users by username.
12//! ## Caveats:
13//! - The API is changing by the minute at the current stage, and this can break this crate.
14//! - JavaScript and by that JSON uses 64-bit numbers, so all numbers in this crate have to be
15//! either u64's or i64's
16//! ## Usage:
17//! This crate consists of Endpoint's and Query's.
18//! Endpoints are just the simple API endpoints, which does not take any arguments.
19//! Queries are API endpoints, which take one or more arguments, such as "/search/some_username".
20
21#![deny(missing_docs)]
22#![feature(format_args_capture)]
23/// Defines a bunch of Endpoint implementing structs, which do not take any arguments.
24pub mod endpoints;
25mod util;
26/// Defines Query implementing structs, which do take one or more arguments.
27pub mod queries;
28#[cfg(test)]
29mod test;
30
31#[derive(Debug)]
32/// Error type for any error that could occur after sending a request to the Dogehouse API.
33pub enum ErrorType {
34 /// Constructed when the API Endpoint didn't return the `200` status code. Contains the
35 /// returned status code by the API.
36 NotFound(u16),
37 /// Constructed when the API didn't return valid JSON, or without valid fields.
38 /// Contains serde_json's error.
39 ParseError(serde_json::Error),
40 /// Constructed when for some reason reqwest's get() doesn't return an Ok() value.
41 NoHTTP(&'static str),
42}
43
44// This is free and unencumbered software released into the public domain.
45//
46// Anyone is free to copy, modify, publish, use, compile, sell, or
47// distribute this software, either in source code form or as a compiled
48// binary, for any purpose, commercial or non-commercial, and by any
49// means.
50//
51// In jurisdictions that recognize copyright laws, the author or authors
52// of this software dedicate any and all copyright interest in the
53// software to the public domain. We make this dedication for the benefit
54// of the public at large and to the detriment of our heirs and
55// successors. We intend this dedication to be an overt act of
56// relinquishment in perpetuity of all present and future rights to this
57// software under copyright law.
58//
59// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
60// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
63// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
64// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
65// OTHER DEALINGS IN THE SOFTWARE.
66//
67// For more information, please refer to <http://unlicense.org/>