Skip to main content

eth_avatars/modules/http/
mod.rs

1use std::str::FromStr;
2
3use crate::{Locator, LocatorError, Resource};
4
5#[cfg(feature = "reqwest")]
6pub mod client;
7#[cfg(feature = "reqwest")]
8pub use client::HttpFetcher;
9
10#[derive(Debug, PartialEq, Eq)]
11pub struct Http {
12    pub url: String,
13}
14
15impl FromStr for Http {
16    type Err = LocatorError;
17
18    fn from_str(s: &str) -> Result<Self, Self::Err> {
19        Ok(Self { url: s.to_string() })
20    }
21}
22
23impl Locator for Http {
24    fn of(resource: &Resource) -> Option<&Self> {
25        match resource {
26            Resource::Http(http) => Some(http),
27            _ => None,
28        }
29    }
30}