mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-13 05:42:59 +00:00
Implement Copy for peer::Receipt
This commit is contained in:
parent
a7f812e059
commit
08991db882
2 changed files with 14 additions and 2 deletions
|
@ -28,7 +28,6 @@ type MessageHandler = Box<
|
||||||
dyn Send + Sync + Fn(&mut Option<proto::Envelope>, ConnectionId) -> Option<BoxFuture<bool>>,
|
dyn Send + Sync + Fn(&mut Option<proto::Envelope>, ConnectionId) -> Option<BoxFuture<bool>>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
pub struct Receipt<T> {
|
pub struct Receipt<T> {
|
||||||
sender_id: ConnectionId,
|
sender_id: ConnectionId,
|
||||||
message_id: u32,
|
message_id: u32,
|
||||||
|
@ -376,6 +375,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Clone for Receipt<T> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Self {
|
||||||
|
sender_id: self.sender_id,
|
||||||
|
message_id: self.message_id,
|
||||||
|
payload_type: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Copy for Receipt<T> {}
|
||||||
|
|
||||||
impl fmt::Display for ConnectionId {
|
impl fmt::Display for ConnectionId {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.0.fmt(f)
|
self.0.fmt(f)
|
||||||
|
@ -391,6 +402,7 @@ impl fmt::Display for PeerId {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use postage::oneshot;
|
||||||
use smol::{
|
use smol::{
|
||||||
io::AsyncWriteExt,
|
io::AsyncWriteExt,
|
||||||
net::unix::{UnixListener, UnixStream},
|
net::unix::{UnixListener, UnixStream},
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/zed.messages.rs"));
|
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;
|
const NAME: &'static str;
|
||||||
fn into_envelope(
|
fn into_envelope(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Reference in a new issue