pub trait SinkSocket: IntoInnerSocket {
    fn send(
        self,
        multipart: Multipart
    ) -> <<Self as IntoInnerSocket>::Socket as InnerSocket<Self>>::Request { ... } fn sink(
        self,
        buffer_size: usize
    ) -> <<Self as IntoInnerSocket>::Socket as InnerSocket<Self>>::Sink { ... } }
Expand description

This trait provides the basic Sink support for ZeroMQ Sockets. It depends on IntoInnerSocket and provides the send and sink methods.

Provided Methods

Send a single multipart message to the socket.

Example, using a Pub wrapper type
extern crate zmq;
extern crate futures;
extern crate tokio;
extern crate tokio_zmq;

use std::sync::Arc;

use futures::Future;
use tokio_zmq::{prelude::*, async_types::MultipartStream, Error, Pub};

fn main() {
    let context = Arc::new(zmq::Context::new());
    let msg = zmq::Message::from_slice(b"Hello").unwrap();
    let fut = Pub::builder(context)
        .connect("tcp://localhost:5569")
        .build()
        .and_then(|zpub| zpub.send(msg.into()));

    // tokio::run(fut.map(|_| ()).or_else(|e| {
    //     println!("Error: {}", e);
    //     Ok(())
    // }));
}

Send a stream of multipart messages to the socket.

It takes a buffer_size argument, which will determine how many Multiparts can be submitted into the send queue before the sink applies backpressure.

Example, using a Pub wrapper type
extern crate zmq;
extern crate futures;
extern crate tokio;
extern crate tokio_zmq;

use std::sync::Arc;

use futures::{Future, Stream, stream::iter_ok};
use tokio_zmq::{prelude::*, async_types::MultipartStream, Error, Multipart, Pub};

fn main() {
    let context = Arc::new(zmq::Context::new());
    let fut = Pub::builder(context)
        .connect("tcp://localhost:5570")
        .build()
        .and_then(|zpub| {
            iter_ok(0..5)
                .and_then(|i| {
                    let msg = zmq::Message::from_slice(format!("i: {}", i).as_bytes())?;
                    Ok(msg.into()) as Result<Multipart, Error>
                })
                .forward(zpub.sink(25))
        });

    // tokio::run(fut.map(|_| ()).or_else(|e| {
    //     println!("Error: {}", e);
    //     Ok(())
    // }));
}

Implementors