pullcaps/
lib.rs

1//! # pullcaps
2//!
3//! The `pullcaps` crate provides a convenient, opinionated, asynchronous client
4//! for the [PushShift API](https://pushshift.io/).
5//!
6//! ## Getting all comments from a specific user.
7//!
8//! The following example shows a small script that gets all comments made
9//! by a specific user.
10//!
11//! ```rust,no_run
12//! use futures::StreamExt;
13//! use pullcaps::{Client, Filter};
14//!
15//! # #[tokio::main]
16//! # async fn main() {
17//! let client = Client::new();
18//! let filter = Filter::new().author("reddit");
19//!
20//! let mut comments = client.get_comments(filter).await;
21//! while let Some(comment) = comments.next().await {
22//!     println!("text: {}", comment.body);
23//! }
24//! # }
25//! ```
26//!
27//! **NOTE**: If you plan to perform multiple requests, it is best to create a [`Client`]
28//! and reuse it.
29//!
30//! ## Getting posts in a given subreddit
31//!
32//! The following example shows how to get posts from a given subreddit - in particular
33//! we utilize [`futures::StreamExt::take`] to limit ourselves to the five most recent posts
34//! in the subreddit.
35//!
36//! ```rust,no_run
37//! use futures::StreamExt;
38//! use pullcaps::{Client, Filter};
39//!
40//! # #[tokio::main]
41//! # async fn main() {
42//! let client = Client::new();
43//! let filter = Filter::new().subreddit("askreddit");
44//!
45//! let mut posts = client.get_posts(filter).await.take(5);
46//! while let Some(post) = posts.next().await {
47//!     if let Some(text) = post.self_text {
48//!         println!("text: {}", text);
49//!     }
50//! }
51//! # }
52//! ```
53
54pub mod models;
55
56mod client;
57mod filter;
58
59pub use client::Client;
60pub use filter::{Filter, SortType};