zeromq / zmq.rs

A native implementation of ØMQ in Rust
https://crates.io/crates/zeromq
MIT License
1.14k stars 98 forks source link

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

Closed fenjalien closed 4 years ago

fenjalien commented 4 years ago

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* }

fenjalien commented 4 years ago

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