Skip to content

Commit

Permalink
Merge #88: timeout() and socks() don't return Result
Browse files Browse the repository at this point in the history
561db26 `timeout()` and `socks()` don't return Result (Riccardo Casatta)

Pull request description:

  The `Result` was necessary in the past because they couldn't both be set,
  this is not true anymore after 7493630

ACKs for top commit:
  afilini:
    ACK 561db26

Tree-SHA512: 7654cfbbc7beac6acec786060e373bbc046e1dae0faf2b2ca1df33121e9e92a8f4950c7f8775e44226a62483aeae41c76162cf037ce38137c44d2fedd38560c8
  • Loading branch information
afilini committed Sep 13, 2022
2 parents add1b78 + 561db26 commit 1290819
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/tor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 4 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1290819

Please sign in to comment.