From acadc4a9d993452991f9be6a77d4883b96d1354d Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 14 Nov 2024 11:43:35 -0800 Subject: [PATCH] enostr: add PoolEventBuf to simplify lifetimes in some situations Signed-off-by: William Casarin --- enostr/src/relay/pool.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/enostr/src/relay/pool.rs b/enostr/src/relay/pool.rs index de4e1ef..3856d8d 100644 --- a/enostr/src/relay/pool.rs +++ b/enostr/src/relay/pool.rs @@ -18,6 +18,20 @@ pub struct PoolEvent<'a> { pub event: ewebsock::WsEvent, } +impl<'a> PoolEvent<'a> { + pub fn into_owned(self) -> PoolEventBuf { + PoolEventBuf { + relay: self.relay.to_owned(), + event: self.event + } + } +} + +pub struct PoolEventBuf { + pub relay: String, + pub event: ewebsock::WsEvent, +} + pub struct PoolRelay { pub relay: Relay, pub last_ping: Instant,