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
Auto Trait Implementations§
impl !Freeze for Connection
impl !RefUnwindSafe for Connection
impl !Send for Connection
impl !Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more