Struct orca::net::Connection
source · pub struct Connection {
pub auth: Option<OAuth>,
pub useragent: HeaderValue,
pub client: Client<HttpsConnector<HttpConnector>, Body>,
pub limit: Cell<LimitMethod>,
/* private fields */
}
Expand description
A connection holder to reddit. Holds authorization info if provided, and is in charge of ratelimiting.
Fields§
§auth: Option<OAuth>
Authorization info (optional, but required for sending authorized requests)
useragent: HeaderValue
User agent for the client
client: Client<HttpsConnector<HttpConnector>, Body>
HTTP client
limit: Cell<LimitMethod>
How to ratelimit (burst or steady)
Implementations§
source§impl Connection
impl Connection
sourcepub fn new(
appname: &str,
appversion: &str,
appauthor: &str
) -> Result<Connection, Error>
pub fn new(
appname: &str,
appversion: &str,
appauthor: &str
) -> Result<Connection, Error>
Creates a new connection instance to reddit
Arguments
appname
- The name of the appappversion
- The version of the appappauthor
- The author of the app (should be in reddit form as /u/)
sourcepub fn run_request(&self, req: Request<Body>) -> Result<Value, Error>
pub fn run_request(&self, req: Request<Body>) -> Result<Value, Error>
Send a request to reddit. This is where ratelimiting happens, as well as setting the user agent.
sourcepub fn run_auth_request(&self, req: Request<Body>) -> Result<Value, Error>
pub fn run_auth_request(&self, req: Request<Body>) -> Result<Value, Error>
Send a request to reddit with authorization headers
sourcepub fn set_limit(&self, limit: LimitMethod)
pub fn set_limit(&self, limit: LimitMethod)
Set’s the ratelimiting method