zeromq / zmq.rs

A native implementation of ØMQ in Rust

Home Page:https://crates.io/crates/zeromq

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't create RepSocket when using zmq.rs as a library

fenjalien opened this issue · comments

commented

Hi, new refactor of REQ/REP looking nice, few usage problems however.
You can't create a RepSocket using the new method when not in the zmq.rs folder.

Taking the code from examples/socket_server.rs:

use tokio::net::TcpListener;
use tokio::prelude::*;

use std::convert::TryInto;
use zeromq::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("Start server");
    let mut socket = zeromq::RepSocket::new();
    socket.bind("127.0.0.1:5555").await?;

    loop {
        // TODO refactor me
        let mut repl: String = socket.recv().await.unwrap().try_into().unwrap();
        dbg!(&repl);
        repl.push_str(" Reply");
        socket.send(repl.into()).await.expect("Failed to send");
    }
}

You get the error:

no function or associated item named `new` found for struct `zeromq::req_rep::RepSocket` in the current scope

function or associated item not found in `zeromq::req_rep::RepSocket`

Including this in Cargo.toml:
zeromq = { path = *Absolute path to zmq.rs* }

commented

wops just looked through the source code, seems I'm a bit eager. Sorry!