Skip to main content

ProxyConfig

Struct ProxyConfig 

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

Proxy configuration supporting HTTP, HTTPS, and SOCKS5 proxies.

ยงExamples

use yt_dlp::client::proxy::{ProxyConfig, ProxyType};

// Simple HTTP proxy
let proxy = ProxyConfig::new(ProxyType::Http, "http://proxy.example.com:8080");

// SOCKS5 proxy with authentication
let proxy = ProxyConfig::new(ProxyType::Socks5, "socks5://proxy.example.com:1080")
    .with_auth("username", "password");

// With no-proxy list
let proxy = ProxyConfig::new(ProxyType::Http, "http://proxy.example.com:8080")
    .with_no_proxy(vec!["localhost".to_string(), "127.0.0.1".to_string()]);

Implementationsยง

Sourceยง

impl ProxyConfig

Source

pub fn new(proxy_type: ProxyType, url: impl Into<String>) -> Self

Creates a new proxy configuration.

ยงArguments
  • proxy_type - The type of proxy (HTTP, HTTPS, or SOCKS5)
  • url - The proxy URL (e.g., โ€œhttp://proxy.example.com:8080โ€)
ยงReturns

A new ProxyConfig instance

Source

pub fn with_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self

Adds authentication credentials to the proxy.

ยงArguments
  • username - The proxy username
  • password - The proxy password
ยงReturns

Self for method chaining

Source

pub fn with_no_proxy(self, no_proxy: Vec<String>) -> Self

Sets the list of domains that should bypass the proxy.

ยงArguments
  • no_proxy - List of domains to bypass (e.g., [โ€œlocalhostโ€, โ€œ127.0.0.1โ€])
ยงReturns

Self for method chaining

Source

pub fn proxy_type(&self) -> &ProxyType

Returns the proxy type.

ยงReturns

A reference to the configured ProxyType.

Source

pub fn url(&self) -> &str

Returns the proxy URL.

ยงReturns

The proxy URL as a string slice.

Source

pub fn username(&self) -> Option<&str>

Returns the username if authentication is configured.

ยงReturns

The proxy username, or None if no authentication is set.

Source

pub fn password(&self) -> Option<&str>

Returns the password if authentication is configured.

ยงReturns

The proxy password, or None if no authentication is set.

Source

pub fn no_proxy(&self) -> &[String]

Returns the no-proxy list.

ยงReturns

A slice of domain strings that should bypass the proxy.

Source

pub fn build_url(&self) -> String

Builds the complete proxy URL with authentication if configured.

ยงReturns

The proxy URL with embedded authentication credentials if provided

Source

pub fn to_reqwest_proxy(&self) -> Result<Proxy>

Converts to reqwest proxy format.

ยงReturns

Result containing the reqwest Proxy instance

ยงErrors

Returns error if the proxy URL is invalid

Source

pub fn to_ytdlp_arg(&self) -> String

Converts to yt-dlp proxy argument format.

ยงReturns

The proxy URL in the format expected by yt-dlpโ€™s --proxy argument. Includes authentication credentials if configured.

Trait Implementationsยง

Sourceยง

impl Clone for ProxyConfig

Sourceยง

fn clone(&self) -> ProxyConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for ProxyConfig

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Sourceยง

impl Display for ProxyConfig

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> Downcast for T
where T: Any,

Sourceยง

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Sourceยง

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Sourceยง

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Anyโ€™s vtable from &Traitโ€™s.
Sourceยง

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Anyโ€™s vtable from &mut Traitโ€™s.
Sourceยง

impl<T> DowncastSend for T
where T: Any + Send,

Sourceยง

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Sourceยง

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Sourceยง

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Sourceยง

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> โ“˜

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Sourceยง

impl<T> DynClone for T
where T: Clone,

Sourceยง

fn __clone_box(&self, _: Private) -> *mut ()

Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self> โ“˜

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self> โ“˜

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Sourceยง

const ALIGN: usize

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Sourceยง

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

Sourceยง

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Sourceยง

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T> ToString for T
where T: Display + ?Sized,

Sourceยง

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> โ“˜
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self> โ“˜

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more