From 1746d2bb6accfdb61c397c3e66c3cb4396b24410 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Tue, 7 Jul 2026 11:36:49 +0200 Subject: [PATCH] pv: Change ec_key() to return Option<&PKeyRef> Prepare the API for future host keys that might not have an EC key by returning Option instead of a direct reference. Additionally, use &PKeyRef as the borrowed view on PKey for better API consistency. Signed-off-by: Marc Hartmayer Reviewed-by: Timo Keller Reviewed-by: Steffen Eiden Signed-off-by: Steffen Eiden --- rust/pv/src/req/hostkey.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/pv/src/req/hostkey.rs b/rust/pv/src/req/hostkey.rs index 9edf673e..d50cb3f3 100644 --- a/rust/pv/src/req/hostkey.rs +++ b/rust/pv/src/req/hostkey.rs @@ -4,7 +4,7 @@ //! Host key types for UV requests -use openssl::pkey::{PKey, Public}; +use openssl::pkey::{PKey, PKeyRef, Public}; /// Versioned host keys container #[non_exhaustive] @@ -16,10 +16,10 @@ pub enum HostKey { impl HostKey { /// Return the ECDH public key - pub fn ec_key(&self) -> &PKey { - match self { + pub fn ec_key(&self) -> Option<&PKeyRef> { + Some(match self { HostKey::V1(ec_key) => ec_key, - } + }) } }