From 44d854e03a09ea7e28ddd78e0e11d8d8e0d14218 Mon Sep 17 00:00:00 2001 From: monica Date: Wed, 4 Jan 2023 15:22:44 -0500 Subject: [PATCH] added explicit lifetime for session refs --- zssp/src/applicationlayer.rs | 4 ++-- zssp/src/tests.rs | 4 ++-- zssp/src/zssp.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zssp/src/applicationlayer.rs b/zssp/src/applicationlayer.rs index 68358aa95..b07af5d67 100644 --- a/zssp/src/applicationlayer.rs +++ b/zssp/src/applicationlayer.rs @@ -19,7 +19,7 @@ pub trait ApplicationLayer: Sized { type Data; /// Arbitrary object that dereferences to the session, such as Arc>. - type SessionRef: Deref>; + type SessionRef<'a>: Deref>; /// A buffer containing data read from the network that can be cached. /// @@ -57,7 +57,7 @@ pub trait ApplicationLayer: Sized { fn extract_s_public_from_raw(static_public: &[u8]) -> Option; /// Look up a local session by local session ID or return None if not found. - fn lookup_session(&self, local_session_id: SessionId) -> Option; + fn lookup_session<'a>(&self, local_session_id: SessionId) -> Option>; /// Rate limit and check an attempted new session (called before accept_new_session). fn check_new_session(&self, rc: &ReceiveContext, remote_address: &Self::RemoteAddress) -> bool; diff --git a/zssp/src/tests.rs b/zssp/src/tests.rs index 96e4e62bb..3ba061c12 100644 --- a/zssp/src/tests.rs +++ b/zssp/src/tests.rs @@ -45,7 +45,7 @@ mod tests { impl ApplicationLayer for Box { type Data = u32; - type SessionRef = Arc>>; + type SessionRef<'a> = Arc>>; type IncomingPacketBuffer = Vec; type RemoteAddress = u32; @@ -67,7 +67,7 @@ mod tests { P384PublicKey::from_bytes(static_public) } - fn lookup_session(&self, local_session_id: SessionId) -> Option { + fn lookup_session<'a>(&self, local_session_id: SessionId) -> Option> { self.session.lock().unwrap().as_ref().and_then(|s| { if s.id == local_session_id { Some(s.clone()) diff --git a/zssp/src/zssp.rs b/zssp/src/zssp.rs index b34184dd0..ff1d561d3 100644 --- a/zssp/src/zssp.rs +++ b/zssp/src/zssp.rs @@ -638,7 +638,7 @@ impl ReceiveContext { canonical_header_bytes: &[u8; 12], fragments: &[Application::IncomingPacketBuffer], packet_type: u8, - session: Option, + session: Option>, mtu: usize, current_time: i64, ) -> Result, Error> {