Skip to content

Commit

Permalink
feat: add IpcSender::send_clone
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Mar 29, 2022
1 parent f6b3d8f commit 30e2da0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ impl<T> IpcSender<T> where T: Serialize {
})
}

/// Send data across the channel to the receiver.
pub fn send(&self, data: T) -> Result<(), bincode::Error> {
fn send_internal(&self, data: &T) -> Result<(), bincode::Error> {
let mut bytes = Vec::with_capacity(4096);
OS_IPC_CHANNELS_FOR_SERIALIZATION.with(|os_ipc_channels_for_serialization| {
OS_IPC_SHARED_MEMORY_REGIONS_FOR_SERIALIZATION.with(
Expand All @@ -380,6 +379,15 @@ impl<T> IpcSender<T> where T: Serialize {
})
}

/// Send data across the channel to the receiver.
pub fn send(&self, data: T) -> Result<(), bincode::Error> {
self.send_internal(&data)
}

pub fn send_clone(&self, data: &T) -> Result<(), bincode::Error> where T: Clone {
self.send_internal(data)
}

pub fn to_opaque(self) -> OpaqueIpcSender {
OpaqueIpcSender {
os_sender: self.os_sender,
Expand Down

0 comments on commit 30e2da0

Please sign in to comment.