| 276 | |
| 277 | impl<S: IntoUrl> IntoProxyScheme for S { |
| 278 | fn into_proxy_scheme(self) -> Result<ProxyScheme, ProxyError> { |
| 279 | // validate the URL |
| 280 | let url = match self.as_str().into_url() { |
| 281 | Ok(ok) => ok, |
| 282 | Err(e) => { |
| 283 | match e { |
| 284 | // If the string does not contain protocol headers, try to parse it using the socks5 protocol |
| 285 | ProxyError::UrlParseScheme(_source) => { |
| 286 | let try_this = format!("socks5://{}", self.as_str()); |
| 287 | try_this.into_url()? |
| 288 | } |
| 289 | _ => { |
| 290 | return Err(e); |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | }; |
| 295 | ProxyScheme::parse(url) |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | impl IntoProxyScheme for ProxyScheme { |