Crate crates_io_api [] [src]

API client for crates.io.

It aims to provide an easy to use and complete client for retrieving information about Rust's crate ecosystem.

Note: Right now, only a synchronous client is available. Once the Async version of hyper stabilizes, an asynchronous client based on Tokio will be added.

Examples

Print the most downloaded crates and their non-optional dependencies:

use crates_io_api::{SyncClient, Result};
fn list_top_dependencies() -> Result<()> {
    // Instantiate the client.
    let client = SyncClient::new()?;
    // Retrieve summary data.
    let summary = client.summary()?;
    for c in summary.most_downloaded {
        println!("{}:", c.id);
        for dep in client.crate_dependencies(&c.id, &c.max_version)? {
            // Ignore optional dependencies.
            if !dep.optional {
                println!("    * {} - {}", dep.id, dep.version_id);
            }
        }
    }
    Ok(())
}

Modules

types

Types for the data that is available via the API.

Structs

Error

The Error type.

ListOptions

Options for the crates method of the client.

SyncClient

A synchronous client for the crates.io API.

Enums

ErrorKind

The kind of an error.

Sort

Used to specify the sort behaviour of the Client::crates() method.

Traits

ResultExt

Additional methods for Result, for easy interaction with this crate.

Type Definitions

Result

Convenient wrapper around std::Result.