Skip to content

Commit

Permalink
Make Options builder consuming
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarema committed May 1, 2022
1 parent bb3a21b commit c4809af
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions async-nats/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl ConnectOptions {
/// # Ok(())
/// # }
/// ```
pub fn add_root_certificates(&mut self, path: PathBuf) -> &mut ConnectOptions {
pub fn add_root_certificates(mut self, path: PathBuf) -> ConnectOptions {
self.certificates = vec![path];
self
}
Expand All @@ -150,7 +150,7 @@ impl ConnectOptions {
/// # Ok(())
/// # }
/// ```
pub fn add_client_certificate(&mut self, cert: PathBuf, key: PathBuf) -> &mut ConnectOptions {
pub fn add_client_certificate(mut self, cert: PathBuf, key: PathBuf) -> ConnectOptions {
self.client_cert = Some(cert);
self.client_key = Some(key);
self
Expand All @@ -167,7 +167,7 @@ impl ConnectOptions {
/// # Ok(())
/// # }
/// ```
pub fn require_tls<'a>(&'a mut self, is_required: bool) -> &'a mut ConnectOptions {
pub fn require_tls(mut self, is_required: bool) -> ConnectOptions {
self.tls_required = is_required;
self
}
Expand All @@ -185,7 +185,7 @@ impl ConnectOptions {
/// # Ok(())
/// # }
/// ```
pub fn flush_interval(&mut self, flush_interval: Duration) -> &mut ConnectOptions {
pub fn flush_interval(mut self, flush_interval: Duration) -> ConnectOptions {
self.flush_interval = flush_interval;
self
}
Expand All @@ -201,28 +201,28 @@ impl ConnectOptions {
/// # Ok(())
/// # }
/// ```
pub fn ping_interval(&mut self, ping_interval: Duration) -> &mut ConnectOptions {
pub fn ping_interval(mut self, ping_interval: Duration) -> ConnectOptions {
self.ping_interval = ping_interval;
self
}

pub fn error_callback<F>(&mut self, cb: F) -> &mut ConnectOptions
pub fn error_callback<F>(mut self, cb: F) -> ConnectOptions
where
F: Fn(ServerError) -> BoxFuture<'static, ()> + Send + Sync + 'static,
{
self.error_callback = ErrorCallback(Some(Box::new(cb)));
self
}

pub fn reconnect_callback<F>(&mut self, cb: F) -> &mut ConnectOptions
pub fn reconnect_callback<F>(mut self, cb: F) -> ConnectOptions
where
F: Fn() -> BoxFuture<'static, ()> + Send + Sync + 'static,
{
self.reconnect_callback = Callback(Some(Box::new(cb)));
self
}

pub fn disconnect_callback<F>(&mut self, cb: F) -> &mut ConnectOptions
pub fn disconnect_callback<F>(mut self, cb: F) -> ConnectOptions
where
F: Fn() -> BoxFuture<'static, ()> + Send + Sync + 'static,
{
Expand Down

0 comments on commit c4809af

Please sign in to comment.