pub struct ProxyUrl {
pub scheme: Scheme,
pub host: String,
pub port: Option<u16>,
pub username: Option<String>,
pub password: Option<String>,
pub path: Option<String>,
}Expand description
A parsed proxy URL — the canonical input shape for check.
The struct is intentionally small (six String / Option fields,
no Vec) and is built once per ingest by
ProxyUrl::parse. The owned String fields make the type
'static-safe; the check function only reads from it and never
mutates. Credentials are carried for completeness but
check never inspects the password component.
§Example
use stygian_proxy::vendor_quirks::{ProxyUrl, Scheme};
let p = ProxyUrl::parse("http://user:pass@proxy.crawlera.com:8011/path")
.expect("parses");
assert_eq!(p.scheme, Scheme::Http);
assert_eq!(p.host, "proxy.crawlera.com");
assert_eq!(p.port, Some(8011));
assert_eq!(p.username.as_deref(), Some("user"));
assert_eq!(p.password.as_deref(), Some("pass"));
assert_eq!(p.path.as_deref(), Some("/path"));
let p = ProxyUrl::parse("https://proxy.test:8443").expect("parses");
assert_eq!(p.scheme, Scheme::Https);
assert_eq!(p.host, "proxy.test");
assert_eq!(p.port, Some(8443));Fields§
§scheme: SchemeURL scheme.
host: StringHost portion of the URL (lower-case, no brackets).
port: Option<u16>Optional port. None means the scheme default (80 for HTTP, 443
for HTTPS).
username: Option<String>Optional user-info username. Never logged by check.
password: Option<String>Optional user-info password. Never logged, matched, or echoed
by check.
path: Option<String>Optional path component (e.g. "/" for http://host:80/).
Implementations§
Source§impl ProxyUrl
impl ProxyUrl
Sourcepub fn parse(url: &str) -> Result<Self, ParseError>
pub fn parse(url: &str) -> Result<Self, ParseError>
Parse a proxy URL into a ProxyUrl.
Recognises http://, https://, and (when the socks feature
is enabled) socks4:// / socks5:// schemes. IPv6 literals in
brackets (e.g. http://[::1]:8080) are supported. User-info is
split on the first : after the // separator so passwords
containing colons survive intact.
§Errors
Returns ParseError when the URL is structurally invalid.
The error message includes the original URL for diagnostics.
§Example
use stygian_proxy::vendor_quirks::{ProxyUrl, Scheme};
let p = ProxyUrl::parse("http://user:pa:ss@host:8080").unwrap();
assert_eq!(p.scheme, Scheme::Http);
assert_eq!(p.host, "host");
assert_eq!(p.port, Some(8080));
assert_eq!(p.username.as_deref(), Some("user"));
// Passwords containing colons are preserved.
assert_eq!(p.password.as_deref(), Some("pa:ss"));Trait Implementations§
impl Eq for ProxyUrl
impl StructuralPartialEq for ProxyUrl
Auto Trait Implementations§
impl Freeze for ProxyUrl
impl RefUnwindSafe for ProxyUrl
impl Send for ProxyUrl
impl Sync for ProxyUrl
impl Unpin for ProxyUrl
impl UnsafeUnpin for ProxyUrl
impl UnwindSafe for ProxyUrl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.