pub struct IconService { /* private fields */ }Expand description
Docker image icon service
Fetches Docker image icons from various sources including Docker Hub, GitHub Container Registry, and devicons.
§Example
use dimicon::IconService;
#[tokio::main]
async fn main() {
let service = IconService::new();
if let Some(icon) = service.get_icon("nginx").await.unwrap() {
println!("Icon URL: {}", icon.url());
}
}Implementations§
Source§impl IconService
impl IconService
Sourcepub fn with_client(client: Client) -> Self
pub fn with_client(client: Client) -> Self
Create a new icon service instance with a custom HTTP client
Sourcepub async fn get_icon(&self, image: &str) -> Result<Option<IconSource>>
pub async fn get_icon(&self, image: &str) -> Result<Option<IconSource>>
Get the icon for an image
Tries multiple sources in order of priority:
- Registry-specific free sources (Docker Official Image logo, GHCR avatar)
- devicons/devicon via jsDelivr CDN (requires
deviconfeature) - Rate-limited Docker Hub APIs (org Gravatar, image logo)
Returns Ok(None) if no icon could be found.
Sourcepub async fn get_icon_for_ref(
&self,
parsed: &ImageReference,
) -> Result<Option<IconSource>>
pub async fn get_icon_for_ref( &self, parsed: &ImageReference, ) -> Result<Option<IconSource>>
Get the icon for a parsed image reference
Sourcepub async fn get_icon_with_source(&self, image: &str) -> Result<Option<Icon>>
pub async fn get_icon_with_source(&self, image: &str) -> Result<Option<Icon>>
Get the icon with its source metadata and downloaded image data
Like get_icon, but also fetches the actual image
bytes from the resolved URL.
Sourcepub async fn get_icon_with_source_for_ref(
&self,
parsed: &ImageReference,
) -> Result<Option<Icon>>
pub async fn get_icon_with_source_for_ref( &self, parsed: &ImageReference, ) -> Result<Option<Icon>>
Get the icon with source for a parsed image reference
Trait Implementations§
Source§impl Clone for IconService
impl Clone for IconService
Source§impl Debug for IconService
impl Debug for IconService
Auto Trait Implementations§
impl !RefUnwindSafe for IconService
impl !UnwindSafe for IconService
impl Forget for IconService
impl Freeze for IconService
impl Move for IconService
impl Send for IconService
impl Sync for IconService
impl Unpin for IconService
impl UnsafeUnpin for IconService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more