1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! # 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](https://github.com/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
//!
//! ```no_run
//! 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
//!
//! | Registry | Icon Source |
//! |----------|-------------|
//! | Docker Hub (docker.io) | Image logo, Org Gravatar, Official Image logo |
//! | GitHub Container Registry (ghcr.io) | GitHub Avatar |
//! | Other registries | Not supported (returns `None`) |
pub use ;
pub use ImageReference;
pub use IconService;
pub use ;
/// Convenience function to get an icon for an image
///
/// Creates a new [`IconService`] for each call. For better performance
/// when fetching multiple icons, create a single service and reuse it.
///
/// # Example
///
/// ```no_run
/// #[tokio::main]
/// async fn main() {
/// if let Some(icon) = dimicon::get_icon("nginx").await.unwrap() {
/// println!("Icon URL: {}", icon.url());
/// }
/// }
/// ```
pub async
/// Convenience function to get an icon with its source metadata and image data
///
/// Creates a new [`IconService`] for each call. For better performance
/// when fetching multiple icons, create a single service and reuse it.
///
/// # Example
///
/// ```no_run
/// #[tokio::main]
/// async fn main() {
/// if let Some(icon) = dimicon::get_icon_with_source("nginx").await.unwrap() {
/// println!("Source: {:?}, {} bytes", icon.source(), icon.data().len());
/// }
/// }
/// ```
pub async