[][src]Trait libzmq::prelude::SendMsg

pub trait SendMsg: GetRawSocket {
    fn send<M>(&self, msg: M) -> Result<(), Error<Msg>>
    where
        M: Into<Msg>
, { ... }
fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>>
    where
        M: Into<Msg>
, { ... }
fn send_hwm(&self) -> Result<i32, Error> { ... }
fn set_send_hwm(&self, hwm: i32) -> Result<(), Error> { ... }
fn send_timeout(&self) -> Result<Period, Error> { ... }
fn set_send_timeout<P>(&self, period: P) -> Result<(), Error>
    where
        P: Into<Period>
, { ... } }

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>, 

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

fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
    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

fn send_hwm(&self) -> Result<i32, 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.

Default

1000

Example

use libzmq::{prelude::*, *};

let client = ClientBuilder::new().build()?;
assert_eq!(client.send_hwm()?, 1000);

fn set_send_hwm(&self, hwm: i32) -> Result<(), Error>

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.

Usage Contract

  • The high water mark cannot be zero.

Returned Error

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>, 

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());
Loading content...

Implementors

impl SendMsg for Client[src]

impl SendMsg for Radio[src]

impl SendMsg for Scatter[src]

impl SendMsg for Server[src]

Loading content...