Skip to main content

Crate dimicon

Crate dimicon 

Source
Expand description

§dimicon — Docker Image Icon

A Rust library for fetching Docker image icons from various sources.

§Features

  • Fetch icons from Docker Hub image logos
  • Fetch icons from Docker Hub organization Gravatars
  • Fetch icons from devicons/devicon (via jsDelivr CDN)
  • Fetch icons from Docker Official Images (via jsDelivr CDN)
  • Fetch icons from GitHub Container Registry (via GitHub Avatar)
  • Parse Docker image reference strings

§Quick Start

use dimicon::IconService;

#[tokio::main]
async fn main() -> Result<(), dimicon::Error> {
    let service = IconService::new();

    if let Some(icon) = service.get_icon("nginx").await? {
        println!("nginx icon: {}", icon.url());
    }

    Ok(())
}

§Image Reference Parsing

use dimicon::ImageReference;

let img = ImageReference::parse("nginx").unwrap();
assert!(img.is_docker_official());

let img = ImageReference::parse("nginx:latest").unwrap();
assert_eq!(img.tag(), Some("latest"));

let img = ImageReference::parse("myuser/myimage:v1.0").unwrap();
assert_eq!(img.namespace(), "myuser");

let img = ImageReference::parse("ghcr.io/owner/app:latest").unwrap();
assert!(img.is_ghcr());

§Supported Registries

RegistryIcon Source
Docker Hub (docker.io)Image logo, Org Gravatar, Official Image logo
GitHub Container Registry (ghcr.io)GitHub Avatar
Other registriesNot supported (returns None)

Structs§

Icon
A resolved icon with its source metadata and raw image data
IconService
Docker image icon service
ImageReference
A parsed Docker image reference

Enums§

Error
dimicon library error types
IconSource
Image icon source

Functions§

get_icon
Convenience function to get an icon for an image
get_icon_with_source
Convenience function to get an icon with its source metadata and image data

Type Aliases§

Result