Skip to content

Commit c0e904f

Browse files
committed
fix(core): implement Clone manually on Channel.
ref: tauri-apps/plugins-workspace#2479 (comment)
1 parent dc78dfe commit c0e904f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.changes/channel-clone.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": "patch:bug"
3+
---
4+
5+
Removed `TSend: Clone` requirement for `Channel<TSend>` by implementing `Clone` manually instead of driving it.

crates/tauri/src/ipc/channel.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ static CHANNEL_DATA_COUNTER: AtomicU32 = AtomicU32::new(0);
3535
pub struct ChannelDataIpcQueue(pub(crate) Arc<Mutex<HashMap<u32, InvokeResponseBody>>>);
3636

3737
/// An IPC channel.
38-
#[derive(Clone)]
3938
pub struct Channel<TSend = InvokeResponseBody> {
4039
id: u32,
4140
on_message: Arc<dyn Fn(InvokeResponseBody) -> crate::Result<()> + Send + Sync>,
@@ -49,6 +48,16 @@ const _: () = {
4948
struct Channel<TSend>(std::marker::PhantomData<TSend>);
5049
};
5150

51+
impl<TSend> Clone for Channel<TSend> {
52+
fn clone(&self) -> Self {
53+
Self {
54+
id: self.id,
55+
on_message: self.on_message.clone(),
56+
phantom: Default::default(),
57+
}
58+
}
59+
}
60+
5261
impl<TSend> Serialize for Channel<TSend> {
5362
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
5463
where

0 commit comments

Comments
 (0)