pub struct ConfigBuilder { /* private fields */ }
Expand description
Config Builder
Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a builder with a default config, equivalent to ConfigBuilder::default()
Examples found in repository?
examples/tor.rs (line 9)
5fn main() {
6 // NOTE: This assumes Tor is running localy, with an unauthenticated Socks5 listening at
7 // localhost:9050
8 let proxy = Socks5Config::new("127.0.0.1:9050");
9 let config = ConfigBuilder::new().socks5(Some(proxy)).build();
10
11 let client = Client::from_config("tcp://explorernuoc63nb.onion:110", config.clone()).unwrap();
12 let res = client.server_features();
13 println!("{:#?}", res);
14
15 // works both with onion v2/v3 (if your Tor supports them)
16 let client = Client::from_config(
17 "tcp://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion:110",
18 config,
19 )
20 .unwrap();
21 let res = client.server_features();
22 println!("{:#?}", res);
23}
Sourcepub fn socks5(self, socks5_config: Option<Socks5Config>) -> Self
pub fn socks5(self, socks5_config: Option<Socks5Config>) -> Self
Set the socks5 config if Some, it accept an Option
because it’s easier for the caller to use
in a method chain
Examples found in repository?
examples/tor.rs (line 9)
5fn main() {
6 // NOTE: This assumes Tor is running localy, with an unauthenticated Socks5 listening at
7 // localhost:9050
8 let proxy = Socks5Config::new("127.0.0.1:9050");
9 let config = ConfigBuilder::new().socks5(Some(proxy)).build();
10
11 let client = Client::from_config("tcp://explorernuoc63nb.onion:110", config.clone()).unwrap();
12 let res = client.server_features();
13 println!("{:#?}", res);
14
15 // works both with onion v2/v3 (if your Tor supports them)
16 let client = Client::from_config(
17 "tcp://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion:110",
18 config,
19 )
20 .unwrap();
21 let res = client.server_features();
22 println!("{:#?}", res);
23}
Sourcepub fn validate_domain(self, validate_domain: bool) -> Self
pub fn validate_domain(self, validate_domain: bool) -> Self
Sets if the domain has to be validated
Sourcepub fn build(self) -> Config
pub fn build(self) -> Config
Return the config and consume the builder
Examples found in repository?
examples/tor.rs (line 9)
5fn main() {
6 // NOTE: This assumes Tor is running localy, with an unauthenticated Socks5 listening at
7 // localhost:9050
8 let proxy = Socks5Config::new("127.0.0.1:9050");
9 let config = ConfigBuilder::new().socks5(Some(proxy)).build();
10
11 let client = Client::from_config("tcp://explorernuoc63nb.onion:110", config.clone()).unwrap();
12 let res = client.server_features();
13 println!("{:#?}", res);
14
15 // works both with onion v2/v3 (if your Tor supports them)
16 let client = Client::from_config(
17 "tcp://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion:110",
18 config,
19 )
20 .unwrap();
21 let res = client.server_features();
22 println!("{:#?}", res);
23}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConfigBuilder
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more