[][src]Struct env_proxy::ProxyUrl

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.

Implementations

impl ProxyUrl[src]

pub fn raw_value(self) -> Option<String>[src]

Return the raw value of the proxy URL.

pub fn is_none(self) -> bool[src]

Return true if the None value is wrapped.

pub 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()] (#method.with_no_default_port) on the instance.

pub fn with_no_default_port(self) -> Self[src]

Don't use the default port value when transforming the raw URL.

pub 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. If the raw URL lacks the scheme, http is assumed and "http://" is prepended to canonicalize the value;
  • 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.

pub 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()).

pub 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()).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.