summaryrefslogtreecommitdiffstats
path: root/librepology/src/lib.rs
blob: 8b4cdb36b688078a3cd836353e1002e7b0537a53 (plain)
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
//! librepology
//!
//! This library can be used to talk to the repology API.
//!
//! # Example
//!
//! ```
//! use librepology::endpoint::DefaultEndpoint;
//! use librepology::v1::api::ApiClient;
//! use librepology::v1::api::ToRequest;
//! use librepology::v1::types::response::Problem;
//!
//! # async fn result_main() -> librepology::v1::error::Result<()> {
//! ApiClient::new::<DefaultEndpoint>()?
//!     .problems()
//!     .for_repo(String::from("freebsd")) // sorry guys, you're the example here
//!     .to_request()
//!     .perform()
//!     .await?
//!     .into_iter()
//!     .for_each(|problem| println!("Problem: {:?}", problem));
//! # Ok(())
//! # }
//! ```
//!
//! # Details
//!
//! The `ApiClient` type is the type you need to talk to repology. It is generic over a endpoint
//! URI, which can be set via a implementor of `librepology::endpoint::EndpointUrl`.
//!
//! The entry points for building an API request are `ApiClient::problems()` and
//! `ApiClient::project()`. They return builder-pattern objects that can be used to build the
//! request.
//!
//! After all parameters of the request are set, the `ToRequest::to_request()` function can be used
//! to transform the builder into a `librepology::v1::api::Request`, that can be (async) `Request::perform()`ed.
//!
//! The `Request::perform()` returns the appropriate type for your request, so if you
//! called `ApiClient::problems()` it does the right thing and returns a `Vec<Problem>`.
//!

pub mod v1;
pub mod endpoint;