use anyhow::{Error, Result};
use reqwest::Proxy as P;
pub struct Proxy(pub P);
impl Proxy {
pub fn http(url: &str) -> Result<Self> {
Ok(Self(P::http(url)?))
}
pub fn https(url: &str) -> Result<Self> {
Ok(Self(P::https(url)?))
}
}
impl std::str::FromStr for Proxy {
type Err = Error;
fn from_str(url: &str) -> Result<Self, Self::Err> {
Ok(if url.starts_with("https://") {
Self::https(url)?
} else {
Self::http(url)?
})
}
}