Skip to main content

Crate eth_avatars

Crate eth_avatars 

Source
Expand description

eth-avatars is a library for fetching avatars, resolving urls, and more.

In simplest terms, the crate turns “ipfs://..” and “eip155:…” into your preferred output (Url or Vec<u8>).

This crate is not limited to just avatars, it also works great for banners, and much more.

§Overview

Here is a simple example showing off how you can use eth-avatars:

use eth_avatars::{Client, modules::{ipfs::IpfsGateway, http::HttpFetcher}};

#[tokio::main]
pub async fn main() {
    let http_client = reqwest::Client::default();
    let client = Client::default()
        .with_fetcher(IpfsGateway::new("https://ipfs.io/"))
        .with_fetcher(HttpFetcher::from(http_client));

    let resource = "ipfs://bafkreifnrjhkl7ccr2ifwn2n7ap6dh2way25a6w5x2szegvj5pt4b5nvfu".parse().unwrap();
    let data = client.fetch(resource).await.unwrap();
}

§Configurable Sources

You can configure any of the below sources (one minimum) to support a protocol.

§Features

reqwest enables reqwest support.

Re-exports§

pub use client::Client;
pub use error::FetchError;
pub use error::LocatorError;
pub use modules::AnyFetcher;
pub use modules::Fetcher;
pub use resource::Locator;
pub use resource::Resource;

Modules§

client
error
modules
resource
utils