timeout() and socks() don't return Result

The `Result` was necessary in the past because they couldn't both be set,
this is not true anymore after 7493630ed8
This commit is contained in:
Riccardo Casatta 2022-09-05 15:56:28 +02:00
parent add1b7853e
commit 561db261d3
No known key found for this signature in database
GPG Key ID: FD986A969E450397
3 changed files with 6 additions and 9 deletions

View File

@ -6,7 +6,7 @@ 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)).unwrap().build();
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();

View File

@ -404,10 +404,7 @@ mod tests {
let now = Instant::now();
let client = Client::from_config(
&endpoint,
crate::config::ConfigBuilder::new()
.timeout(Some(5))
.unwrap()
.build(),
crate::config::ConfigBuilder::new().timeout(Some(5)).build(),
);
let elapsed = now.elapsed();

View File

@ -44,15 +44,15 @@ impl ConfigBuilder {
/// Set the socks5 config if Some, it accept an `Option` because it's easier for the caller to use
/// in a method chain
pub fn socks5(mut self, socks5_config: Option<Socks5Config>) -> Result<Self, Error> {
pub fn socks5(mut self, socks5_config: Option<Socks5Config>) -> Self {
self.config.socks5 = socks5_config;
Ok(self)
self
}
/// Sets the timeout
pub fn timeout(mut self, timeout: Option<u8>) -> Result<Self, Error> {
pub fn timeout(mut self, timeout: Option<u8>) -> Self {
self.config.timeout = timeout.map(|t| Duration::from_secs(t as u64));
Ok(self)
self
}
/// Sets the retry attempts number