Function ipc_channel::ipc::channel

source ·
pub fn channel<T>() -> Result<(IpcSender<T>, IpcReceiver<T>), Error>where
    T: for<'de> Deserialize<'de> + Serialize,
Expand description

Create a connected IpcSender and IpcReceiver that transfer messages of a given type provided by type T or inferred by the types of messages sent by the sender.

Messages sent by the sender will be available to the receiver even if the sender or receiver has been moved to a different process. In addition, receivers and senders may be sent over an existing channel.


let payload = "Hello, World!".to_owned();

// Create a channel
let (tx, rx) = ipc::channel().unwrap();

// Send data

// Receive the data
let response = rx.recv().unwrap();

assert_eq!(response, "Hello, World!".to_owned());