pub struct Security { /* private fields */ }Expand description
Information about transport security (TLS/SSL) successfully negotiated on a port.
Implementations§
Source§impl Security
impl Security
Sourcepub fn tls_version(&self) -> Option<&str>
pub fn tls_version(&self) -> Option<&str>
Returns the negotiated TLS version, if any.
Sourcepub fn cipher_suite(&self) -> Option<&str>
pub fn cipher_suite(&self) -> Option<&str>
Returns the negotiated cipher suite, if any.
Sourcepub fn certificate(&self) -> Option<&CertificateInfo>
pub fn certificate(&self) -> Option<&CertificateInfo>
Returns the certificate information, if available.
Sourcepub fn with_tls_version(self, version: impl Into<String>) -> Self
pub fn with_tls_version(self, version: impl Into<String>) -> Self
Builder method to set the negotiated TLS version.
Sourcepub fn with_cipher_suite(self, cipher: impl Into<String>) -> Self
pub fn with_cipher_suite(self, cipher: impl Into<String>) -> Self
Builder method to set the negotiated cipher suite.
Sourcepub fn add_alpn(self, protocol: impl Into<String>) -> Self
pub fn add_alpn(self, protocol: impl Into<String>) -> Self
Builder method to add an ALPN protocol string.
Sourcepub fn with_certificate(self, cert: CertificateInfo) -> Self
pub fn with_certificate(self, cert: CertificateInfo) -> Self
Builder method to attach parsed certificate information.
Sourcepub fn merge(&mut self, other: Security)
pub fn merge(&mut self, other: Security)
Merges another security record into this one.
Preserves existing TLS version and cipher suite if already populated, but safely deduplicates and merges ALPN arrays.
Sourcepub fn is_cert_valid(&self) -> bool
pub fn is_cert_valid(&self) -> bool
Returns true if the certificate is actively valid at the current system time.
Returns false if the certificate is expired, not yet valid, or missing.
Sourcepub fn is_cert_valid_at(&self, target_time: SystemTime) -> bool
pub fn is_cert_valid_at(&self, target_time: SystemTime) -> bool
Returns true if the certificate is valid at a specific target time.
Sourcepub fn is_cert_expiring(&self, threshold: Duration) -> bool
pub fn is_cert_expiring(&self, threshold: Duration) -> bool
Returns true if the certificate is currently valid, but expires within the given threshold.
§Examples
use std::time::Duration;
// Check if the certificate expires in the next 30 days
let expires_soon = sec.is_cert_expiring(Duration::from_secs(86400 * 30));Trait Implementations§
impl Eq for Security
impl StructuralPartialEq for Security
Auto Trait Implementations§
impl Freeze for Security
impl RefUnwindSafe for Security
impl Send for Security
impl Sync for Security
impl Unpin for Security
impl UnsafeUnpin for Security
impl UnwindSafe for Security
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more