-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09_get-news.rs
41 lines (35 loc) · 1.04 KB
/
09_get-news.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Gets the news items.
//!
//! Run the following Cargo command to run this example:
//!
//! ```bash
//! cargo run --example 09_get-news
//! ```
use tetr_ch::prelude::*;
#[tokio::main]
async fn main() {
let client = Client::new();
// Get three latest news items in any stream.
let _ = client.get_news_all(3).await.unwrap();
// Gets the latest news items in the global news stream.
let _ = client
.get_news_latest(
// The global news stream.
NewsStreamParam::Global,
// Three news
3,
)
.await
.unwrap();
// Gets the latest news items in the specified user's news stream.
let _ = client
.get_news_latest(
// The news stream of the user `621db46d1d638ea850be2aa0`
NewsStreamParam::User("621db46d1d638ea850be2aa0".to_string()),
3,
)
.await
.unwrap();
// For more information about the data structure, see:
// https://docs.rs/tetr_ch/latest/tetr_ch/model/news/struct.NewsItems.html
}