Struct env_proxy::ProxyUrl
[−]
[src]
pub struct ProxyUrl(_, _);
A wrapper for the proxy URL retrieved from the environment.
This struct will wrap the raw value of the URL, which is only guaranteed to be valid UTF-8 when returned. Various methods exist to extract the value as-is, translate it into other forms, and provide elements of interest.
Methods
impl ProxyUrl
[src]
fn raw_value(self) -> Option<String>
[src]
Return the raw value of the proxy URL.
fn is_none(self) -> bool
[src]
Return true
if the None
value is wrapped.
fn with_default_port(self, port: u16) -> Self
[src]
Set the default port to use when transforming the raw URL value if the port isn't specified in the URL.
A ProxyUrl
instance returned by the library will have the default
port set to 8080, which corresponds to http-alt in the IANA port
registry. This is different from curl, which uses port 1080 as the default.
To skip the default port substitution, use with_no_default_port()
on the instance.
fn with_no_default_port(self) -> Self
[src]
Don't use the default port value when transforming the raw URL.
fn to_url(self) -> Option<Url>
[src]
Transform the raw proxy URL into a Url
.
The transformation will:
- Parse the raw URL as a
Url
; - Ensure that the host part is not empty;
- Use the default value for the port (or not, see
with_default_port()
) if one is not specified in the raw URL. - Ensure that the port is not empty.
If any of the steps fail, None
will be returned.
fn host_port(self) -> Option<(String, u16)>
[src]
Return the (host, port) tuple of the proxy.
The raw URL will first be transformed into a Url
, with any errors in the conversion
producing a None
(see to_url()
).
fn to_string(self) -> Option<String>
[src]
Return the string representation of the proxy URL.
The raw URL will first be transformed into a Url
, with any errors in the conversion
producing a None
(see to_url()
).