1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
#![deny(missing_docs)] //! # orca //! orca is a library to make using the Reddit API from Rust easy //! //! ## Features //! orca has not yet implemented near all of the functionality available in the Reddit API, but //! enough has been implemented to make simple flexible scripts or apps. Some main functionality //! includes: //! //! * submitting self posts //! * automatic ratelimiting //! * commenting and replying //! * comment streams from subreddits //! * private messages //! * authorization as script or installed oauth app type //! * more stuff //! //! ## Structure //! All of the functionality necessary is available in the implementation of //! the `App` struct. Data structures are defined in `orca::data`. Networking code is present in //! the net module, which also contains OAuth authorization functionality. //! //! ## Usage //! To simply create a reddit app instance, do //! //! ```rust //! # use orca::App; //! # let (name, version, author) = ("a", "b", "c"); //! let mut reddit = App::new(name, version, author).unwrap(); //! ``` //! //! where `name`, `version`, and `author` are all `&str`s. //! //! This instance can do actions that don't require authorization, such as retrieving a stream of //! comments from a subreddit, but actions such as commenting require authorization, which can be //! done multiple ways. The most common way for clients to authorize is as scripts, which can be //! done by just providing a username and password as well as the id and secret of the app that can //! be registered on the desktop site. It looks like this in code (assuming you already have a //! mutable reddit instance): //! //! ```rust,no_run //! # use orca::App; //! # let mut reddit = App::new("a", "b", "c").unwrap(); //! # let (id, secret, username, password) = ("a", "b", "c", "d"); //! reddit.authorize_script(id, secret, username, password).unwrap(); //! ``` //! More info can be found in the documentation for the net module //! //! Actually doing something is simple and similar to previous examples. To get info about the //! currently authorized user, simply call //! //! ```rust,no_run //! # use orca::App; //! # let mut reddit = App::new("a", "b", "c").unwrap(); //! reddit.get_self(); //! ``` //! //! which will return a json value until the actual user data structure is implemented. //! extern crate chrono; #[macro_use] extern crate failure; #[macro_use] extern crate failure_derive; extern crate futures; extern crate hyper; extern crate hyper_tls; #[macro_use] extern crate log; extern crate open; extern crate rand; extern crate serde; extern crate serde_json as json; extern crate tokio_core; extern crate url; #[cfg(test)] mod test; /// Functionality for communication with reddit.com pub mod net; /// Reddit data structures pub mod data; /// Errors pub mod errors; /// Main entry point pub mod app; pub use net::auth::{self, InstalledAppError, ResponseGenFn, Scopes}; pub use net::{Connection, LimitMethod}; pub use data::{Sort, SortTime}; pub use errors::RedditError; pub use app::App;