[−][src]Trait libzmq::prelude::SendMsg
Send messages in a thread-safe fashion.
Does not support multipart messages.
Provided methods
fn send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
M: Into<Msg>,
Push a message into the outgoing socket queue.
This operation might block until the mute state end or,
if it set, send_timeout
expires.
If the message is a Msg
, Vec<u8>
, [u8]
, or a String
, it is not copied.
Success
The message was queued and now belongs to ØMQ
Error
In case of an error, the message is not queued and the ownership is returned.
Possible Error Variants
WouldBlock
(ifsend_timeout
expires)CtxTerminated
Interrupted
HostUnreachable
(only forServer
socket)
fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
M: Into<Msg>,
Try to push a message into the outgoing socket queue without blocking.
If the action would block, it returns a WouldBlock
error, otherwise
the message is pushed into the outgoing queue.
If the message is a Msg
, Vec<u8>
, [u8]
, or a String
, it is not copied.
Success
The message was queued and now belongs to ØMQ
Error
In case of an error, the message is not queued and the ownership is returned.
Possible Error Variants
WouldBlock
CtxTerminated
Interrupted
HostUnreachable
(only forServer
socket)
fn send_high_water_mark(&self) -> Result<Quantity, Error>
The high water mark for outbound messages on the specified socket.
The high water mark is a hard limit on the maximum number of outstanding messages ØMQ shall queue in memory.
If this limit has been reached the socket shall enter the mute state
.
fn set_send_high_water_mark<Q>(&self, qty: Q) -> Result<(), Error> where
Q: Into<Quantity>,
Q: Into<Quantity>,
Set the high water mark for outbound messages on the specified socket.
The high water mark is a hard limit on the maximum number of outstanding messages ØMQ shall queue in memory.
If this limit has been reached the socket shall enter the mute state
.
Default value
1000
fn send_timeout(&self) -> Result<Period, Error>
Sets the timeout for [send
] on the socket.
If some timeout is specified, the [send
] will return
[WouldBlock
] after the duration is elapsed. Otherwise,
it will block until the message is sent.
fn set_send_timeout<P>(&self, period: P) -> Result<(), Error> where
P: Into<Period>,
P: Into<Period>,
Sets the timeout for [send
] on the socket.
If some timeout is specified, the [send
] will return
[WouldBlock
] after the duration is elapsed. Otherwise,
it will block until the message is sent.
Default Value
Infinite
Example
use libzmq::{prelude::*, Client, ErrorKind}; use std::time::Duration; let client = Client::new()?; client.set_send_timeout(Some(Duration::from_millis(1)))?; // The client is in mute state so the following would block forever // if a timeout wasn't specified. Instead, it will block for 1ms. let err = client.send("msg").unwrap_err(); assert_eq!(ErrorKind::WouldBlock, err.kind());
Implementors
impl SendMsg for Client
[src]
fn send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
fn send_high_water_mark(&self) -> Result<Quantity, Error>
[src]
fn set_send_high_water_mark<Q>(&self, qty: Q) -> Result<(), Error> where
Q: Into<Quantity>,
[src]
Q: Into<Quantity>,
fn send_timeout(&self) -> Result<Period, Error>
[src]
fn set_send_timeout<P>(&self, period: P) -> Result<(), Error> where
P: Into<Period>,
[src]
P: Into<Period>,
impl SendMsg for Radio
[src]
fn send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
fn send_high_water_mark(&self) -> Result<Quantity, Error>
[src]
fn set_send_high_water_mark<Q>(&self, qty: Q) -> Result<(), Error> where
Q: Into<Quantity>,
[src]
Q: Into<Quantity>,
fn send_timeout(&self) -> Result<Period, Error>
[src]
fn set_send_timeout<P>(&self, period: P) -> Result<(), Error> where
P: Into<Period>,
[src]
P: Into<Period>,
impl SendMsg for Scatter
[src]
fn send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
fn send_high_water_mark(&self) -> Result<Quantity, Error>
[src]
fn set_send_high_water_mark<Q>(&self, qty: Q) -> Result<(), Error> where
Q: Into<Quantity>,
[src]
Q: Into<Quantity>,
fn send_timeout(&self) -> Result<Period, Error>
[src]
fn set_send_timeout<P>(&self, period: P) -> Result<(), Error> where
P: Into<Period>,
[src]
P: Into<Period>,
impl SendMsg for Server
[src]
fn send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
fn send_high_water_mark(&self) -> Result<Quantity, Error>
[src]
fn set_send_high_water_mark<Q>(&self, qty: Q) -> Result<(), Error> where
Q: Into<Quantity>,
[src]
Q: Into<Quantity>,
fn send_timeout(&self) -> Result<Period, Error>
[src]
fn set_send_timeout<P>(&self, period: P) -> Result<(), Error> where
P: Into<Period>,
[src]
P: Into<Period>,