pub struct TlsClient { /* private fields */ }Expand description
TLS secure client for connecting to TLS-enabled servers
Supports optional session resumption for improved reconnection performance. With session resumption, reconnections can skip the full TLS handshake, reducing latency by ~50-70%.
Implementations§
Source§impl TlsClient
impl TlsClient
Sourcepub async fn connect(addr: &str, config: TlsClientConfig) -> Result<Self>
pub async fn connect(addr: &str, config: TlsClientConfig) -> Result<Self>
Connect to a TLS server
Sourcepub async fn connect_with_session(
addr: &str,
config: TlsClientConfig,
session_cache: Option<Arc<SessionCache>>,
) -> Result<Self>
pub async fn connect_with_session( addr: &str, config: TlsClientConfig, session_cache: Option<Arc<SessionCache>>, ) -> Result<Self>
Connect to a TLS server with session resumption support
§Arguments
addr- Server address to connect toconfig- TLS configurationsession_cache- Optional session cache for resumption
§Example
ⓘ
let cache = SessionCache::new(100, Duration::from_secs(3600));
let client = TlsClient::connect_with_session(
"127.0.0.1:8443",
config,
Some(Arc::new(cache))
).await?;Sourcepub async fn request(&mut self, message: Message) -> Result<Message>
pub async fn request(&mut self, message: Message) -> Result<Message>
Send a message and wait for a response
Sourcepub fn session_cache(&self) -> Option<&SessionCache>
pub fn session_cache(&self) -> Option<&SessionCache>
Get the session cache if configured
Sourcepub fn session_id(&self) -> Option<&str>
pub fn session_id(&self) -> Option<&str>
Get the session identifier
Auto Trait Implementations§
impl !Freeze for TlsClient
impl !RefUnwindSafe for TlsClient
impl Send for TlsClient
impl Sync for TlsClient
impl Unpin for TlsClient
impl !UnwindSafe for TlsClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more