A smol rust crate for fetching Ethereum avatars from various sources.
Ethereum Avatars come in all shapes and sizes, sometimes its ipfs:// sometimes eip155: and plenty others.
To easily integrate these into your application eth-avatars takes care of the resolution for you.
cargo add eth-avatarsuse 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();
}Currently supported data sources include:
- Http -
http://&https://with reqwest - Ipfs -
ipfs://&ipns:// - Swarm -
bzz:// - Arweave -
ar:// - Ethereum -
eip155:
Every source is opt-in by default.
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();
}You can read the documentation at docs.rs/eth-avatars.