Function hadean::hadean::connect[][src]

pub fn connect(
    pid: Pid
) -> Pin<Box<dyn Future<Output = Result<(UntypedSender, UntypedReceiver), HadeanError>> + Send>>
Expand description

Connect with another process that is ready to accept incomming connections.

Arguments

  • pid - identifier of the process we are interested in connecting with

Result

If successful, the function returns UntypedSender and UntypedReceiver objects which can be used to exchange raw bytes between the processes.

Note: You may find it useful to convert the sender and receiver into typed equivalents i.e. Sender<T> and Receiver<T>

Examples

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