Struct electrum_client::ConfigBuilder
source · 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)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() {
// NOTE: This assumes Tor is running localy, with an unauthenticated Socks5 listening at
// localhost:9050
let proxy = Socks5Config::new("127.0.0.1:9050");
let config = ConfigBuilder::new().socks5(Some(proxy)).build();
let client = Client::from_config("tcp://explorernuoc63nb.onion:110", config.clone()).unwrap();
let res = client.server_features();
println!("{:#?}", res);
// works both with onion v2/v3 (if your Tor supports them)
let client = Client::from_config(
"tcp://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion:110",
config,
)
.unwrap();
let res = client.server_features();
println!("{:#?}", res);
}
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)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() {
// NOTE: This assumes Tor is running localy, with an unauthenticated Socks5 listening at
// localhost:9050
let proxy = Socks5Config::new("127.0.0.1:9050");
let config = ConfigBuilder::new().socks5(Some(proxy)).build();
let client = Client::from_config("tcp://explorernuoc63nb.onion:110", config.clone()).unwrap();
let res = client.server_features();
println!("{:#?}", res);
// works both with onion v2/v3 (if your Tor supports them)
let client = Client::from_config(
"tcp://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion:110",
config,
)
.unwrap();
let res = client.server_features();
println!("{:#?}", res);
}
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)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() {
// NOTE: This assumes Tor is running localy, with an unauthenticated Socks5 listening at
// localhost:9050
let proxy = Socks5Config::new("127.0.0.1:9050");
let config = ConfigBuilder::new().socks5(Some(proxy)).build();
let client = Client::from_config("tcp://explorernuoc63nb.onion:110", config.clone()).unwrap();
let res = client.server_features();
println!("{:#?}", res);
// works both with onion v2/v3 (if your Tor supports them)
let client = Client::from_config(
"tcp://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion:110",
config,
)
.unwrap();
let res = client.server_features();
println!("{:#?}", res);
}