[go: up one dir, main page]

ProxyBuilder

Struct ProxyBuilder 

Source
pub struct ProxyBuilder { /* private fields */ }
Expand description

Builder for configuring a proxy.

Obtained via Proxy::builder().

Implementations§

Source§

impl ProxyBuilder

Source

pub fn host(self, host: &str) -> Self

Set the proxy hostname

Defaults to localhost. Invalid hostnames surface in ProxyBuilder::build().

Source

pub fn port(self, port: u16) -> Self

Set the proxy port

Defaults to whatever is default for the chosen ProxyProtocol.

Source

pub fn username(self, v: &str) -> Self

Set the username

Defaults to none. Invalid usernames surface in ProxyBuilder::build().

Source

pub fn password(self, v: &str) -> Self

Set the password

If you want to set only a password, no username, i.e. https://secret@foo.com, you need to set it as ProxyBuilder::username().

Defaults to none. Invalid passwords surface in ProxyBuilder::build().

Source

pub fn resolve_target(self, do_resolve: bool) -> Self

Whether to resolve the target host locally before calling the proxy.

  • true - resolve target host locally before calling proxy.
  • false - let proxy resolve the host.

For SOCKS4, this defaults to true, for all other protocols false. I.e. in the “normal” case, we let the proxy itself resolve host names.

Source

pub fn no_proxy(self, expr: &str) -> Self

Add a NO_PROXY expression to not route proxy through.

Correct expressions are:

  • example.com -> Literally match example.com, but not sub.example.com
  • .example.com -> Match sub.example.com and foo.sub.example.com, but not example.com.
  • *.example.com -> Exactly like .example.com
  • * -> Match everything

Silently ignores expressions that are not on the above form.

Source

pub fn build(self) -> Result<Proxy, Error>

Construct the Proxy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.