Module hadean::channel[][src]

Expand description

This module provides typed and untyped channels.

Each channel consists of a send-half and a receive-half. The connect and accept functions provide us with UntypedSender and UntypedReceiver objects. These can be converted to typed variants: Sender<T> and Receiver<T>. When using typed channels, the sender and receiver can use different types.

Examples

Parent:

let pid = hadean::spawn(child).await?;
let (sender, receiver) = hadean::connect(pid).await?;
let (mut sender, mut receiver): (Sender<String>, Receiver<String>)
    = (sender.into(), receiver.into());
sender.send(String::from("hello!")).await?;
let message = receiver.next().await?;
println!("received: {}", message);

Child:

let (sender, receiver) = hadean::accept().await?;
let (mut sender, mut receiver): (Sender<String>, Receiver<String>)
    = (sender.into(), receiver.into());
sender.send(String::from("hello!")).await?;
let message = receiver.next().await?;
println!("received: {}", message);

Structs

Receiver

Typed receiver (stream)

Sender

Typed sender (sink)

UntypedReceiver

Untyped receiver

UntypedSender

Untyped sender

Type Definitions

ReceiverImpl
SenderImpl