From cbc21e40acfc420a3e452a1fd488c6a96694b0f2 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 22 Jul 2022 14:45:28 +0200 Subject: [PATCH] Impose static lifetime on message and response --- src/endpoint.rs | 6 +++--- src/message.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/endpoint.rs b/src/endpoint.rs index a402fec..bb768de 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -27,7 +27,7 @@ where /// use the unit type `()` as the handler type: /// it will panic if it is ever made to handle request. #[async_trait] -impl EndpointHandler for () { +impl EndpointHandler for () { async fn handle(self: &Arc<()>, _m: &M, _from: NodeID) -> M::Response { panic!("This endpoint should not have a local handler."); } @@ -50,7 +50,7 @@ where impl StreamingEndpointHandler for T where T: EndpointHandler, - M: Message + 'static, + M: Message, { async fn handle(self: &Arc, mut m: Req, from: NodeID) -> Resp { // Immediately drop stream to avoid backpressure if a stream was sent @@ -177,7 +177,7 @@ where #[async_trait] impl GenericEndpoint for EndpointArc where - M: Message + 'static, + M: Message, H: StreamingEndpointHandler + 'static, { async fn handle(&self, req_enc: ReqEnc, from: NodeID) -> Result { diff --git a/src/message.rs b/src/message.rs index 629992d..ff9861c 100644 --- a/src/message.rs +++ b/src/message.rs @@ -42,8 +42,8 @@ pub const PRIO_SECONDARY: RequestPriority = 0x01; /// This trait should be implemented by all messages your application /// wants to handle -pub trait Message: Serialize + for<'de> Deserialize<'de> + Send + Sync { - type Response: Serialize + for<'de> Deserialize<'de> + Send + Sync; +pub trait Message: Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static { + type Response: Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static; } // ----