From 49a8d0906a5b96ac0e06f6110c3fc49889c2f995 Mon Sep 17 00:00:00 2001 From: 0x676e67 Date: Tue, 8 Apr 2025 01:05:27 +0800 Subject: [PATCH] feat(x509): Implement `Clone` for `X509Store` (#339) * boring(x509): impl Clone of X509Store --- boring/src/x509/store.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/boring/src/x509/store.rs b/boring/src/x509/store.rs index 0f626838..76edac15 100644 --- a/boring/src/x509/store.rs +++ b/boring/src/x509/store.rs @@ -125,6 +125,23 @@ foreign_type_and_impl_send_sync! { pub struct X509Store; } +impl Clone for X509Store { + fn clone(&self) -> Self { + (**self).to_owned() + } +} + +impl ToOwned for X509StoreRef { + type Owned = X509Store; + + fn to_owned(&self) -> Self::Owned { + unsafe { + ffi::X509_STORE_up_ref(self.as_ptr()); + X509Store::from_ptr(self.as_ptr()) + } + } +} + impl X509StoreRef { /// **Warning: this method is unsound** ///