eth_avatars/lib.rs
1/*!
2`eth-avatars` is a library for fetching avatars, resolving urls, and more.
3
4In simplest terms, the crate turns "ipfs://.." and "eip155:..." into your preferred output (`Url` or `Vec<u8>`).
5
6This crate is not limited to just avatars, it also works great for banners, and much more.
7
8# Overview
9
10Here is a simple example showing off how you can use `eth-avatars`:
11```rust
12use eth_avatars::{Client, modules::{ipfs::IpfsGateway, http::HttpFetcher}};
13
14#[tokio::main]
15pub async fn main() {
16 let http_client = reqwest::Client::default();
17 let client = Client::default()
18 .with_fetcher(IpfsGateway::new("https://ipfs.io/"))
19 .with_fetcher(HttpFetcher::from(http_client));
20
21 let resource = "ipfs://bafkreifnrjhkl7ccr2ifwn2n7ap6dh2way25a6w5x2szegvj5pt4b5nvfu".parse().unwrap();
22 let data = client.fetch(resource).await.unwrap();
23}
24```
25
26## Configurable Sources
27
28You can configure any of the below sources (one minimum) to support a protocol.
29
30- [`Http`](`modules::http::Http`)
31 - [`http::HttpFetcher`](`modules::http::HttpFetcher`)
32- [`Ipfs`](`modules::ipfs::Ipfs`)
33 - [`ipfs::IpfsGateway`](`modules::ipfs::IpfsGateway`)
34- [`Swarm`](`modules::swarm::Swarm`) module is still under development
35- [`Arweave`](`modules::arweave::Arweave`) module is still under development
36- [`Ethereum`](`modules::ethereum::Ethereum`)
37 - [`ethereum::EthereumResolver`](`modules::ethereum::EthereumResolver`)
38
39## Features
40
41`reqwest` enables reqwest support.
42
43*/
44
45pub mod client;
46pub mod error;
47pub mod modules;
48pub mod resource;
49pub mod utils;
50
51pub use {
52 client::Client,
53 error::{FetchError, LocatorError},
54 modules::{AnyFetcher, Fetcher},
55 resource::{Locator, Resource},
56};