Enum rmoods_backend::reddit::request::RedditRequest
source · pub enum RedditRequest {
SubredditPosts {
subreddit: String,
params: FeedRequestParams,
},
SubredditInfo {
subreddit: String,
},
UserPosts {
username: String,
params: FeedRequestParams,
},
UserInfo {
username: String,
},
PostComments {
subreddit: String,
post_id: String,
params: FeedRequestParams,
},
}
Expand description
Represents a request to the Reddit API.
Used to fetch posts, comments, and user/subreddit information. The request is then converted into an HTTP request parts tuple.
§Example
use params::{FeedRequestParams, FeedSorting, FeedSortingTime, RequestSize}};
let req = RedditRequest::SubredditPosts {
subreddit: "Polska".to_string(),
params: FeedRequestParams {
size: RequestSize::Medium,
sorting: FeedSorting::New,
},
};
let (url, query) = req.into_http_request_parts();
assert_eq!(url, "https://oauth.reddit.com/r/Polska/new.json");
assert_eq!(query, vec![("limit", "250".to_string()), ("sort", "new".to_string())]);
Variants§
SubredditPosts
Fetch posts from a subreddit.
SubredditInfo
Fetch information about a subreddit.
UserPosts
Fetch posts from a user’s profile.
UserInfo
Fetch information about a user.
PostComments
Fetch comments from a post.
Implementations§
source§impl RedditRequest
impl RedditRequest
sourcepub fn into_http_request_parts(self) -> (String, Vec<(&'static str, String)>)
pub fn into_http_request_parts(self) -> (String, Vec<(&'static str, String)>)
Convert the request into RequestParts
Router method for converting any variant of a RedditRequest into RequestParts.
sourcefn subreddit_posts_to_http(
subreddit: &str,
params: FeedRequestParams,
) -> (String, Vec<(&'static str, String)>)
fn subreddit_posts_to_http( subreddit: &str, params: FeedRequestParams, ) -> (String, Vec<(&'static str, String)>)
Convert RedditRequest::SubredditPosts into RequestParts
sourcefn subreddit_info_to_http(
subreddit: &str,
) -> (String, Vec<(&'static str, String)>)
fn subreddit_info_to_http( subreddit: &str, ) -> (String, Vec<(&'static str, String)>)
Convert RedditRequest::SubredditInfo into RequestParts
sourcefn user_posts_to_http(
username: &str,
params: FeedRequestParams,
) -> (String, Vec<(&'static str, String)>)
fn user_posts_to_http( username: &str, params: FeedRequestParams, ) -> (String, Vec<(&'static str, String)>)
Convert RedditRequest::UserPosts into RequestParts
sourcefn user_info_to_http(username: &str) -> (String, Vec<(&'static str, String)>)
fn user_info_to_http(username: &str) -> (String, Vec<(&'static str, String)>)
Convert RedditRequest::UserInfo into RequestParts
sourcefn post_comments_to_http(
subreddit: &str,
post_id: &str,
params: FeedRequestParams,
) -> (String, Vec<(&'static str, String)>)
fn post_comments_to_http( subreddit: &str, post_id: &str, params: FeedRequestParams, ) -> (String, Vec<(&'static str, String)>)
Convert RedditRequest::PostComments into RequestParts
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RedditRequest
impl RefUnwindSafe for RedditRequest
impl Send for RedditRequest
impl Sync for RedditRequest
impl Unpin for RedditRequest
impl UnwindSafe for RedditRequest
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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