Function hadean::hadean::accept[][src]

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

Accept an incomming connection from some process wanting to connect with us.

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::accept().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);