Crate hub_tool

Crate hub_tool 

Source
Expand description

A (very early) asynchronous Rust library for the Docker Hub API v2

This library exposes a client to interact with the Docker Hub via the Docker Hub API v2, enabling and making it easier to get information about repositories, tags, et al. from the Docker Hub via Rust; as well as to e.g. perform Hub maintenance tasks.

§Usage

use anyhow::Context;
use hub_tool::DockerHubClient;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = DockerHubClient::new("dckr_pat_***")
        .context("couldn't initialize the docker client")?;

    // Fetch the repositories under a given org or username on the Docker Hub
    let repositories = client.list_repositories("ollama")
        .await
        .context("failed while fetching the repositories")?;

    // Fetch the tags for a given repository on the Docker Hub
    let tags = client.list_tags("ollama", "quantize")
        .await
        .context("failed while fetching the tags")?;

    Ok(())
}

Modules§

repositories
tags

Structs§

ApiResult
DockerHubClient
Struct that holds the client and the URL to send request to the Docker Hub

Functions§

fetch