Module rawr::client
[−]
[src]
A client that represents one connection to the Reddit API. This can log in to one account or remain anonymous, and performs all interactions with the Reddit API.
Examples
Creating a RedditClient
When creating a RedditClient
, you are only required to pass in a user agent string, which will
identify your client. The user agent should identify your program, but does not need to
be unique to this particular machine - you should use one user agent for each version of
your program. You must use a descriptive user agent when creating the client to comply
with Reddit API rules.
The recommended format for user agent strings is platform:program:version (by /u/yourname)
,
e.g. linux:rawr:v0.0.1 (by /u/Aurora0001)
.
You also need to pass in an Authenticator. rawr
provides multiple authenticators that
use the different authentication flows provided by Reddit. To get started, you may just want
to browse anonymously. For this, AnonymousAuthenticator
is provided, which can browse
reddit without any IDs or credentials.
If you need logged-in privileges, you need to choose a different authenticator. For most
purposes, the appropriate authenticator will be PasswordAuthenticator
. See the auth
module
for examples of usage and benefits of this.
use rawr::client::RedditClient; use rawr::auth::AnonymousAuthenticator; let agent = "linux:rawr:v0.0.1 (by /u/Aurora0001)"; let client = RedditClient::new(agent, AnonymousAuthenticator::new());
Structs
RedditClient |
A client to connect to Reddit. See the module-level documentation for examples. |