krate

Crates.iokrate
lib.rskrate
version1.0.0
sourcesrc
created_at2023-01-29 00:55:57.261372
updated_at2023-02-03 16:31:45.708372
descriptionGet information and metadata for published Rust crates.
homepage
repositoryhttps://github.com/TheLarkInn/krate
max_upload_size
id770682
size42,305
Sean Larkin (TheLarkInn)

documentation

README

krate 📦

Asynchonously get information and metadata for a Rust Crate published on Crates.io!

krate additionally comes with struct Krate which contains a partially implemented data model for the &Crates.io API/V1 Contract.

NOTE: Currently there is no publically docuemented API contract for the Crates.io API/V1 Contract so any changes or null values passed via the API could break serialization. 🤷‍♂️

Please see the crawler policy on Crates.io if you are planning to use this library to crawl or access the crates data.

Usage

$> cargo add krate

main.rs

use krate::KrateClientBuilder;

#[tokio::main]
async fn main() {
    // Create a KrateClient
    let client = KrateClientBuilder::new("My User Agent Tool")
        .build_async()
        .unwrap();
    
    match client.get_async("serde").await {
        Ok(serde_crate) => {
            println!("Krate: {}", serde_crate.krate.name);
            println!("Latest Version: {}", serde_crate.get_latest());
            println!("Description: {}", serde_crate.krate.description );
        },
        Err(e) => println!("Error: {e}"),
    }    
}

This is a very small implementation! For more robust client see @TheDuke's crates-io-api

Commit count: 30

cargo fmt