runng
High-level wrapper around NNG.
Features:
- Use of nng_aio for asynchronous I/O
- Use of nng_ctx for advanced protocol handling
- Leverage futures crate for ease of use with tokio and eventual support of
async
/await
Sample
High-level wrapper around NNG.
Features:
async
/await
#[test]
fn aio() -> Result<(), NngFail> {
let url = String::from("inproc://test");
let factory = Latest::new();
let mut rep_ctx = factory
.replier_open()?
.listen(&url)?
.create_async_context()?;
let requester = factory.requester_open()?.dial(&url)?;
let mut req_ctx = requester.create_async_context()?;
let req_future = req_ctx.send(msg::NngMsg::new()?);
rep_ctx.receive()
.take(1).for_each(|request|{
let msg = msg::NngMsg::new().unwrap();
rep_ctx.reply(msg).wait().unwrap();
Ok(())
}).wait();
req_future.wait().unwrap()?;
Ok(())
}