crates_io_api_wasm_patch/lib.rs
1//! API client for [crates.io](https://crates.io).
2//!
3//! It aims to provide an easy to use and complete client for retrieving
4//! information about Rust's crate ecosystem.
5//!
6//! Both a [AsyncClient](struct.AsyncClient.html) and a [SyncClient](struct.SyncClient.html) are available, providing either a
7//! Futures based or a blocking interface.
8//!
9//! Please read the official crates.io [Crawler Policy](https://crates.io/policies#crawlers)
10//! before using this crate.
11//!
12//! Due to this policy, you must specify both a user agent and a desired
13//! rate limit delay when constructing a client.
14//! See [SyncClient::new](struct.SyncClient.html#method.new) and [AsyncClient::new](struct.AsyncClient.html#method.new) for more information.
15//!
16//! # Examples
17//!
18//! Print the most downloaded crates and their non-optional dependencies:
19//!
20//! ```rust
21//! use crates_io_api::{SyncClient, Error};
22//!
23//! fn list_top_dependencies() -> Result<(), Error> {
24//! // Instantiate the client.
25//! let client = SyncClient::new(
26//! "my-user-agent (my-contact@domain.com)",
27//! std::time::Duration::from_millis(1000),
28//! ).unwrap();
29//! // Retrieve summary data.
30//! let summary = client.summary()?;
31//! for c in summary.most_downloaded {
32//! println!("{}:", c.id);
33//! for dep in client.crate_dependencies(&c.id, &c.max_version)? {
34//! // Ignore optional dependencies.
35//! if !dep.optional {
36//! println!(" * {} - {}", dep.id, dep.version_id);
37//! }
38//! }
39//! }
40//! Ok(())
41//! }
42//! ```
43
44#![recursion_limit = "128"]
45#![deny(missing_docs)]
46#![cfg_attr(docsrs, feature(doc_cfg))]
47
48mod async_client;
49mod error;
50#[cfg(not(target_arch = "wasm32"))]
51#[cfg_attr(docsrs, doc(cfg(not(target_arch = "wasm32"))))]
52mod sync_client;
53mod types;
54mod util;
55
56pub use crate::{
57 async_client::Client as AsyncClient,
58 error::{Error, NotFoundError, PermissionDeniedError},
59 types::*,
60};
61
62#[cfg(not(target_arch = "wasm32"))]
63#[cfg_attr(docsrs, doc(cfg(not(target_arch = "wasm32"))))]
64pub use crate::sync_client::SyncClient;