[][src]Struct redbot::Config

pub struct Config {
    pub username: String,
    pub password: String,
    pub user_agent: String,
    pub client_id: String,
    pub client_secret: String,
}

Program configuration - contains the required values to communicate with the Reddit OAuth API for a token.

The username and password fields are the same login strings that you'd use to log into the account on the Reddit website. The user_agent field is for setting the 'User Agent' header value to use when communicating with the API, as per the API usage requirements. The client_id and client_secret fields are for a 'script' type application that you create on the Reddit website.

Fields

username: String

Account username

password: String

Account password

user_agent: String

User agent to use

client_id: String

App client id

client_secret: String

App client secret

Methods

impl Config[src]

pub fn load_config(path: &str) -> Result<Self, ApiError>[src]

Attempt to load the configuration from a file.

Arguments

  • path - relative path to the file

Examples

A file called 'config.json' is has the content:

{
  "username": "my-bot-account",
  "password": "hunter2",
  "user_agent": "linux:reddit-rust:v.0.0.1 (bot by /u/my-main-account)",
  "client_id": "foo",
  "client_secret": "bar"
}

Retrieve the config with:

This example is not tested
let config = Config::load_config("config.json")?;

Trait Implementations

impl PartialEq<Config> for Config[src]

impl Clone for Config[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Config[src]

impl<'de> Deserialize<'de> for Config[src]

Auto Trait Implementations

impl Send for Config

impl Sync for Config

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Erased for T

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err