[][src]Trait libzmq::prelude::Heartbeating

pub trait Heartbeating: GetRawSocket {
    fn heartbeat(&self) -> Option<Heartbeat> { ... }
fn set_heartbeat(&self, maybe: Option<Heartbeat>) -> Result<(), Error> { ... } }

A trait that indicates that the socket supports configurable heartbeating.

The actual heartbeating will be done by the engine in the background.

Only applies to connection based transports such as TCP.

Contract

  • timeout and interval duration in ms cannot exceed i32::MAX
  • ttl duration in ms cannot exceed 6553599

Default value

None (no heartbeating)

Return Errors

  • [InvalidInput]: (if contract is not respected)

Example

use libzmq::{prelude::*, Client, Heartbeat, auth::*};
use std::time::Duration;

let client = Client::new()?;
assert_eq!(client.heartbeat(), None);

let duration = Duration::from_millis(300);
let hb = Heartbeat::new(duration)
    .add_timeout(2 * duration);
let expected = hb.clone();

client.set_heartbeat(Some(hb))?;
assert_eq!(client.heartbeat(), Some(expected));

Provided methods

fn heartbeat(&self) -> Option<Heartbeat>

Returns a the socket's heartbeating configuration.

fn set_heartbeat(&self, maybe: Option<Heartbeat>) -> Result<(), Error>

Sets the socket's heartbeating configuration.

Loading content...

Implementors

impl Heartbeating for Client[src]

impl Heartbeating for Gather[src]

impl Heartbeating for Scatter[src]

impl Heartbeating for Server[src]

Loading content...