diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-04-07 19:48:01 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-04-07 19:48:01 +0200 |
commit | 4419c0a106b3913692396fd4720a654b8deeea0c (patch) | |
tree | 9fa01ca58197194b6217f95bf7e65c637124d66f | |
parent | 3f8c8c1e5da70b1c43d0fcea225330ab290fdd0c (diff) |
Add crate doc
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | librepology/src/lib.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/librepology/src/lib.rs b/librepology/src/lib.rs index 83b8184..8b4cdb3 100644 --- a/librepology/src/lib.rs +++ b/librepology/src/lib.rs @@ -1,2 +1,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; |