From 08991db88251b8d065e86163d3d4d6884fb8fb41 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 2 Jul 2021 15:54:22 -0700 Subject: [PATCH] Implement Copy for peer::Receipt --- zed-rpc/src/peer.rs | 14 +++++++++++++- zed-rpc/src/proto.rs | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/zed-rpc/src/peer.rs b/zed-rpc/src/peer.rs index 49f62ec15b..87d07c694e 100644 --- a/zed-rpc/src/peer.rs +++ b/zed-rpc/src/peer.rs @@ -28,7 +28,6 @@ type MessageHandler = Box< dyn Send + Sync + Fn(&mut Option, ConnectionId) -> Option>, >; -#[derive(Clone, Copy)] pub struct Receipt { sender_id: ConnectionId, message_id: u32, @@ -376,6 +375,18 @@ where } } +impl Clone for Receipt { + fn clone(&self) -> Self { + Self { + sender_id: self.sender_id, + message_id: self.message_id, + payload_type: PhantomData, + } + } +} + +impl Copy for Receipt {} + impl fmt::Display for ConnectionId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) @@ -391,6 +402,7 @@ impl fmt::Display for PeerId { #[cfg(test)] mod tests { use super::*; + use postage::oneshot; use smol::{ io::AsyncWriteExt, net::unix::{UnixListener, UnixStream}, diff --git a/zed-rpc/src/proto.rs b/zed-rpc/src/proto.rs index 1db8fe8d01..53001c2020 100644 --- a/zed-rpc/src/proto.rs +++ b/zed-rpc/src/proto.rs @@ -8,7 +8,7 @@ use std::{ include!(concat!(env!("OUT_DIR"), "/zed.messages.rs")); -pub trait EnvelopedMessage: Sized + Send + 'static { +pub trait EnvelopedMessage: Clone + Sized + Send + 'static { const NAME: &'static str; fn into_envelope( self,