Struct Trojan

Source
pub struct Trojan {
    pub host: String,
    pub port: u32,
    pub password: String,
    pub parameters: Option<HashMap<String, String>>,
}
Expand description

Represents a Trojan proxy.

Fields§

§host: String

The host address of the Trojan proxy.

§port: u32

The port number for the Trojan proxy.

§password: String

The password associated with the Trojan proxy.

§parameters: Option<HashMap<String, String>>

Additional parameters associated with the Trojan proxy.

Implementations§

Source§

impl Trojan

Source

pub fn to_url(&self) -> String

Converts the Trojan proxy information into a Trojan URL.

§Example
use std::collections::HashMap;
use proxy_scraper::trojan::Trojan;
let proxy = Trojan {
    host: "example.com".to_string(),
    port: 443,
    password: "password123".to_string(),
    parameters: Some(HashMap::new()), // Insert additional parameters here
};
let url = proxy.to_url();
assert_eq!(url, "trojan://password123@example.com:443?");
Source

pub fn scrape(source: &str) -> Vec<Self>

Scrapes Trojan proxy information from the provided source string and returns a vector of Trojan instances.

§Arguments
  • source - A string containing the source code or text from which to extract Trojan proxy information.
§Returns

A vector of Trojan instances parsed from the source string.

Trait Implementations§

Source§

impl Debug for Trojan

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Trojan

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Trojan

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Trojan

§

impl RefUnwindSafe for Trojan

§

impl Send for Trojan

§

impl Sync for Trojan

§

impl Unpin for Trojan

§

impl UnwindSafe for Trojan

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,