From 6471e38b8307a0553b1761946f80bb08880f1d40 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sun, 16 Feb 2025 11:23:05 -0800 Subject: [PATCH 1/2] feat: add access to underlying config --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 618ddf5..85b5094 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,6 +153,11 @@ impl TlsConnector { session, })) } + + /// Get a read-only reference to underlying config + pub fn config(&self) -> Arc { + self.inner.clone() + } } impl TlsAcceptor { @@ -188,6 +193,11 @@ impl TlsAcceptor { state: TlsState::Stream, })) } + + /// Get a read-only reference to underlying config + pub fn config(&self) -> Arc { + self.inner.clone() + } } pub struct LazyConfigAcceptor { From 27fa9da51f74733a01c720545b85055e9017c79a Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sun, 16 Feb 2025 13:08:23 -0800 Subject: [PATCH 2/2] refactor: use ref instead of clone --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 85b5094..2077a13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,8 +155,8 @@ impl TlsConnector { } /// Get a read-only reference to underlying config - pub fn config(&self) -> Arc { - self.inner.clone() + pub fn config(&self) -> &Arc { + &self.inner } } @@ -195,8 +195,8 @@ impl TlsAcceptor { } /// Get a read-only reference to underlying config - pub fn config(&self) -> Arc { - self.inner.clone() + pub fn config(&self) -> &Arc { + &self.inner } }