From b3216050afe20cb8c8120189ff25849edff10deb Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Fri, 29 Sep 2023 12:11:34 -0400 Subject: [PATCH] fixed mistake in SendTo trait lifetimes --- performance/src/application.rs | 8 +++++--- performance/src/zssp.rs | 16 ++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/performance/src/application.rs b/performance/src/application.rs index a157c83..225460f 100644 --- a/performance/src/application.rs +++ b/performance/src/application.rs @@ -305,7 +305,8 @@ pub trait Sender { /// send packet fragments on some socket or network interface. /// /// Is implemented by `FnMut(&Arc>) -> Option<(Sender, usize)>` closures. -pub trait SendTo { +pub trait SendTo { + type Sender<'a>: Sender where Crypto: 'a, Self: 'a; /// Attempt to process and borrow the resources necessary to repeatedly send fragments of a /// packet to the given session. /// @@ -315,7 +316,7 @@ pub trait SendTo { /// only called once. /// /// If `None` is returned then sending to this session is cancelled. - fn init_send<'a>(&'a mut self, session: &'a Arc>) -> Option<(S, usize)>; + fn init_send<'a>(&'a mut self, session: &'a Arc>) -> Option<(Self::Sender<'a>, usize)>; } impl bool> Sender for F { @@ -324,7 +325,8 @@ impl bool> Sender for F { } } -impl>) -> Option<(S, usize)>, S: Sender> SendTo for F { +impl>) -> Option<(S, usize)>, S: Sender> SendTo for F { + type Sender<'a> = S where Crypto: 'a, F: 'a; fn init_send<'a>(&'a mut self, session: &'a Arc>) -> Option<(S, usize)> { self(session) } diff --git a/performance/src/zssp.rs b/performance/src/zssp.rs index 264d572..9676265 100644 --- a/performance/src/zssp.rs +++ b/performance/src/zssp.rs @@ -190,12 +190,12 @@ impl Context { /// * `remote_address` - Whatever the remote address is, as long as you can Hash it /// * `incoming_fragment_buf` - Buffer containing incoming wire packet (the context takes ownership) /// * `output_buffer` - Buffer to receive decrypted and authenticated object data - pub fn receive<'a, App: ApplicationLayer, S: Sender>( + pub fn receive<'a, App: ApplicationLayer>( &self, mut app: App, mut send_unassociated_reply: impl Sender, mut send_unassociated_mtu: usize, - mut send_to: impl SendTo, + mut send_to: impl SendTo, remote_address: &impl Hash, mut incoming_fragment_buf: Crypto::IncomingPacketBuffer, output_buffer: impl Write, @@ -625,10 +625,10 @@ impl Context { /// /// * `app` - Interface to application using ZSSP /// * `send_to` - Function to get a sender and an MTU to send something over an active session - pub fn service, S: Sender>( + pub fn service>( &self, mut app: App, - send_to: impl SendTo, + send_to: impl SendTo, ) -> i64 { let current_time = app.time(); let next_service_time = self.service_inner(app, send_to, current_time); @@ -652,18 +652,18 @@ impl Context { /// /// * `app` - Interface to application using ZSSP /// * `send_to` - Function to get a sender and an MTU to send something over an active session - pub fn service_scheduled, S: Sender>( + pub fn service_scheduled>( &self, mut app: App, - send_to: impl SendTo, + send_to: impl SendTo, ) -> i64 { let current_time = app.time(); self.service_inner(app, send_to, current_time) } - fn service_inner, S: Sender>( + fn service_inner>( &self, mut app: App, - mut send_to: impl SendTo, + mut send_to: impl SendTo, current_time: i64, ) -> i64 { let ctx = &self.0;