Struct tokio_zmq::async_types::sink::MultipartSink
source · pub struct MultipartSink { /* private fields */ }
Expand description
The MultipartSink
Sink handles sending streams of data to ZeroMQ Sockets.
You shouldn’t ever need to manually create one. Here’s how to get one from a ‘raw’ Socket
’
type.
Example
extern crate zmq;
extern crate futures;
extern crate tokio;
extern crate tokio_zmq;
use std::sync::Arc;
use futures::{Future, Sink};
use tokio_zmq::{prelude::*, Error, Multipart, Pub, Socket};
fn get_sink(socket: Socket) -> impl Sink<SinkItem = Multipart, SinkError = Error> {
socket.sink(25)
}
fn main() {
let context = Arc::new(zmq::Context::new());
let socket = Pub::builder(context)
.bind("tcp://*:5568")
.build()
.unwrap()
.socket();
let sink = get_sink(socket);
let msg = zmq::Message::from_slice(b"Some message");
// tokio::run(sink.send(msg.into())).unwrap();
}
Implementations§
source§impl MultipartSink
impl MultipartSink
pub fn new(buffer_size: usize, sock: Socket, file: EventedFile) -> Self
Trait Implementations§
source§impl Sink for MultipartSink
impl Sink for MultipartSink
source§fn start_send(
&mut self,
multipart: Self::SinkItem
) -> Result<AsyncSink<Self::SinkItem>, Self::SinkError>
fn start_send(
&mut self,
multipart: Self::SinkItem
) -> Result<AsyncSink<Self::SinkItem>, Self::SinkError>
Begin the process of sending a value to the sink. Read more
source§fn poll_complete(&mut self) -> Result<Async<()>, Self::SinkError>
fn poll_complete(&mut self) -> Result<Async<()>, Self::SinkError>
Flush all output from this sink, if necessary. Read more
source§fn close(&mut self) -> Result<Async<()>, Self::SinkError>
fn close(&mut self) -> Result<Async<()>, Self::SinkError>
A method to indicate that no more values will ever be pushed into this
sink. Read more
source§fn wait(self) -> Wait<Self>where
Self: Sized,
fn wait(self) -> Wait<Self>where
Self: Sized,
Creates a new object which will produce a synchronous sink. Read more
source§fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut>where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Self: Sized,
fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut>where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Self: Sized,
Composes a function in front of the sink. Read more
source§fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St>where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Self: Sized,
fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St>where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Self: Sized,
Composes a function in front of the sink. Read more
source§fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::SinkError) -> E,
Self: Sized,
fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::SinkError) -> E,
Self: Sized,
Transforms the error returned by the sink.
source§fn sink_from_err<E>(self) -> SinkFromErr<Self, E>where
E: From<Self::SinkError>,
Self: Sized,
fn sink_from_err<E>(self) -> SinkFromErr<Self, E>where
E: From<Self::SinkError>,
Self: Sized,
Map this sink’s error to any error implementing
From
for this sink’s
Error
, returning a new sink. Read moresource§fn buffer(self, amt: usize) -> Buffer<Self>where
Self: Sized,
fn buffer(self, amt: usize) -> Buffer<Self>where
Self: Sized,
Adds a fixed-size buffer to the current sink. Read more
source§fn flush(self) -> Flush<Self>where
Self: Sized,
fn flush(self) -> Flush<Self>where
Self: Sized,
A future that completes when the sink has finished processing all
pending requests. Read more