runng 0.1.8

High-level wrapper around nng (Nanomsg-Next-Generation) aka Nanomsg2

Rust high-level wrapper around NNG (Nanomsg-Next-Gen)

Features:

Examples

Simple:

use runng::*;
fn test() -> Result<(), NngFail> {
    const url: &str = "inproc://test";
    let factory = Latest::new();
    let rep = factory.replier_open()?.listen(&url)?;
    let req = factory.requester_open()?.dial(&url)?;
    req.send(msg::NngMsg::new()?)?;
    rep.recv()?;
    Ok(())
}

Asynchronous I/O:

extern crate futures;
extern crate runng;
use futures::{
    future::Future,
    stream::Stream,
};
use runng::{
    *,
    protocol::{
        AsyncReply,
        AsyncRequest,
        AsyncSocket,
    },
};

fn aio() -> NngReturn {
    const url: &str = "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(())
}

Additional examples in examples/ folder.