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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! API endpoint modules
//!
//! All endpoints use a builder pattern to construct their parameters.
//!
//! # Example
//!
//! ```rust ,no_run
//! use futures::{StreamExt, TryStreamExt};
//! use serde::Deserialize;
//! use speedrun_api::{
//! api::{self, AsyncQuery, PagedEndpointExt},
//! error::SpeedrunApiResult,
//! SpeedrunApiBuilder,
//! };
//!
//! // The return type for the endpoints we are interested in. More information
//! // is returned by the endpoints, but you can deserialize only what is needed.
//! #[derive(Debug, Deserialize)]
//! struct Game {
//! names: Names,
//! weblink: String,
//! }
//!
//! #[derive(Debug, Deserialize)]
//! struct Names {
//! international: String,
//! }
//!
//! #[tokio::main]
//! pub async fn main() -> SpeedrunApiResult<()> {
//! // Create a new client
//! let client = SpeedrunApiBuilder::new().build_async()?;
//!
//! // Create an endpoint. This endpoint gets Super Mario Sunshine.
//! let endpoint = api::games::Game::builder().id("v1pxjz68").build().unwrap();
//! // Call the endpoint. The return type decides how to represent the returned value.
//! let game: Game = endpoint.query_async(&client).await?;
//!
//! // Create a paginated endpoint. This retrievs a list of all games.
//! let paginated_endpoint = api::games::Games::builder().build().unwrap();
//! // The `PagedEndpointExt` adapters consume the endpoint, so we create a copy.
//! let async_stream = paginated_endpoint.clone();
//! // Call the `PagedEndpointExt::stream()` method to get an async Stream of results.
//! let games: Vec<Game> = async_stream.stream(&client).take(200).try_collect().await?;
//! // Call the `PagedEndpointExt::single_page()` method to retrieve a single page builder.
//! // This retrieves 100 results starting at offset 100.
//! let single_page_endpoint = paginated_endpoint
//! .single_page()
//! .offset(100)
//! .max(100)
//! .build()
//! .unwrap();
//! // This wrapped endpoint can be queried like any normal endpoint, but always returns a
//! // `Vec<T: Deserialize>`.
//! let games: Vec<Game> = single_page_endpoint.query_async(&client).await?;
//! }
//! ```
pub use crateRoot;
pub use ;
pub use ;
pub use ApiError;
pub use ;
pub use ;