pub struct RedditClient { /* private fields */ }
Implementations§
Source§impl RedditClient
impl RedditClient
Sourcepub async fn from_env(client_name: &str) -> Result<Self, RedditError>
pub async fn from_env(client_name: &str) -> Result<Self, RedditError>
Creates a new client, reading from the REDDIT_CLIENT_ID
and
REDDIT_CLIENT_SECRET
for the client_id
and client_secret
,
respectively. This function uses dotenv, so the variables can be kept in
a .env
file at the root of the workspace.
§Errors
This function will error if the credentials provided in the aformentioned environment variables are not able to authenticate on Reddit.
§Panics
This function will panic if either of the aformentioned environment variables are not present.
Sourcepub async fn try_from_env(
client_name: &str,
) -> Result<Result<Self, RedditError>, MissingEnvVariableError>
pub async fn try_from_env( client_name: &str, ) -> Result<Result<Self, RedditError>, MissingEnvVariableError>
Creates a new client, reading from the REDDIT_CLIENT_ID
and
REDDIT_CLIENT_SECRET
for the client_id
and client_secret
,
respectively. This function uses dotenv, so the variables can be kept in
a .env
file at the root of the workspace.
§Errors
This function will error if the aformentioned environment variables are not present or if the credentials provided in them are not able to authenticate on Reddit.
Sourcepub async fn from_config(
__arg0: Config<'_>,
) -> Result<Result<Self, RedditError>, MissingEnvVariableError>
pub async fn from_config( __arg0: Config<'_>, ) -> Result<Result<Self, RedditError>, MissingEnvVariableError>
Sourcepub async fn get_subreddit_posts(
&mut self,
subreddit: &str,
sorting: Sort,
after: Option<&FullName>,
) -> Result<RedditListing, RedditError>
pub async fn get_subreddit_posts( &mut self, subreddit: &str, sorting: Sort, after: Option<&FullName>, ) -> Result<RedditListing, RedditError>
Gets posts from a subreddit, using the specified sorting
and after
options.
§Errors
This function will error for many reasons. See the documentation for
RedditError
for more information.
§Panics
This function will panic if either of the aformentioned environment variables are not present.
Sourcepub async fn get_comments(&mut self) -> Result<Vec<RedditListing>, RedditError>
pub async fn get_comments(&mut self) -> Result<Vec<RedditListing>, RedditError>
Gets the comments for the provided post.
§Errors
This function will error for many reasons. See the documentation for
RedditError
for more information.