Skip to main content

SocketOptions

Struct SocketOptions 

Source
pub struct SocketOptions {
Show 56 fields pub read_buffer_size: usize, pub write_buffer_size: usize, pub recv_timeout: Option<Duration>, pub send_timeout: Option<Duration>, pub handshake_timeout: Duration, pub linger: Option<Duration>, pub reconnect_ivl: Duration, pub reconnect_ivl_max: Duration, pub connect_timeout: Duration, pub recv_hwm: usize, pub send_hwm: usize, pub immediate: bool, pub max_msg_size: Option<usize>, pub routing_id: Option<Bytes>, pub connect_routing_id: Option<Bytes>, pub router_mandatory: bool, pub router_handover: bool, pub probe_router: bool, pub xpub_verbose: bool, pub xpub_manual: bool, pub xpub_welcome_msg: Option<Bytes>, pub xsub_verbose_unsubs: bool, pub conflate: bool, pub tcp_keepalive: i32, pub tcp_keepalive_cnt: i32, pub tcp_keepalive_idle: i32, pub tcp_keepalive_intvl: i32, pub req_correlate: bool, pub req_relaxed: bool, pub rate: i32, pub recovery_ivl: Duration, pub sndbuf: i32, pub rcvbuf: i32, pub multicast_hops: i32, pub tos: i32, pub multicast_maxtpdu: i32, pub ipv6: bool, pub bind_to_device: Option<String>, pub plain_server: bool, pub plain_username: Option<String>, pub plain_password: Option<String>, pub curve_server: bool, pub curve_publickey: Option<[u8; 32]>, pub curve_secretkey: Option<[u8; 32]>, pub curve_serverkey: Option<[u8; 32]>, pub zap_domain: String, pub subscriptions: Vec<Bytes>, pub unsubscriptions: Vec<Bytes>, pub max_reconnect_attempts: Option<u32>, pub heartbeat_ivl: Option<Duration>, pub heartbeat_ttl: Option<Duration>, pub heartbeat_timeout: Option<Duration>, pub router_raw: bool, pub stream_notify: bool, pub xpub_nodrop: bool, pub invert_matching: bool,
}
Expand description

Socket configuration options.

These options control socket behavior including timeouts, buffer sizes, and reliability features. This struct consolidates all socket configuration in one place, following the MongoDB Rust driver pattern.

§Examples

use monocoque_core::options::SocketOptions;
use std::time::Duration;

// Simple case: use defaults
let opts = SocketOptions::default();

// Customize timeouts and buffers
let opts = SocketOptions::default()
    .with_recv_timeout(Duration::from_secs(5))
    .with_send_timeout(Duration::from_secs(5))
    .with_buffer_sizes(16384, 16384);  // 16KB buffers for high-throughput

Fields§

§read_buffer_size: usize

Read buffer size (bytes)

Size of arena-allocated buffer for receiving data.

  • Default: 8192 (8KB) - balanced for most workloads
  • Small (4KB): Low-latency with small messages (< 1KB)
  • Large (16KB): High-throughput with large messages (> 8KB)
§write_buffer_size: usize

Write buffer size (bytes)

Initial capacity of BytesMut buffer for sending data.

  • Default: 8192 (8KB) - balanced for most workloads
  • Small (4KB): Low-latency with small messages
  • Large (16KB): High-throughput with large messages
§recv_timeout: Option<Duration>

Receive timeout (ZMQ_RCVTIMEO)

Maximum time to wait for a receive operation.

  • None: Block indefinitely (default)
  • Some(Duration::ZERO): Non-blocking (return immediately with EAGAIN)
  • Some(duration): Wait up to duration before returning EAGAIN
§send_timeout: Option<Duration>

Send timeout (ZMQ_SNDTIMEO)

Maximum time to wait for a send operation.

  • None: Block indefinitely (default)
  • Some(Duration::ZERO): Non-blocking (return immediately with EAGAIN)
  • Some(duration): Wait up to duration before returning EAGAIN
§handshake_timeout: Duration

Handshake timeout (ZMQ_HANDSHAKE_IVL)

Maximum time to complete ZMTP handshake after connection.

  • Default: 30 seconds
  • Set to Duration::ZERO to disable timeout
§linger: Option<Duration>

Linger timeout (ZMQ_LINGER)

Time to wait for pending messages to be sent before closing socket.

  • None: Close immediately, discard pending messages
  • Some(Duration::ZERO): Same as None
  • Some(duration): Wait up to duration for messages to be sent
§reconnect_ivl: Duration

Reconnect interval (ZMQ_RECONNECT_IVL)

Initial reconnection delay after connection loss.

  • Default: 100ms
  • Use with reconnect_ivl_max for exponential backoff
§reconnect_ivl_max: Duration

Maximum reconnect interval (ZMQ_RECONNECT_IVL_MAX)

Maximum reconnection delay for exponential backoff.

  • Default: 0 (no maximum, use reconnect_ivl always)
  • When > 0: Doubles reconnect_ivl up to this value
§connect_timeout: Duration

Connection timeout (ZMQ_CONNECT_TIMEOUT)

Maximum time to wait for TCP connection to complete.

  • Default: 0 (use OS default)
§recv_hwm: usize

High water mark for receiving (ZMQ_RCVHWM)

Maximum number of messages to queue for receiving. When reached, socket will block or drop messages depending on socket type.

  • Default: 1000 messages
§send_hwm: usize

High water mark for sending (ZMQ_SNDHWM)

Maximum number of messages to queue for sending. When reached, socket will block or drop messages depending on socket type.

  • Default: 1000 messages
§immediate: bool

Enable immediate connect mode (ZMQ_IMMEDIATE)

  • false (default): Queue messages while connecting
  • true: Report error if no connection established
§max_msg_size: Option<usize>

Maximum message size (ZMQ_MAXMSGSIZE)

Maximum size of a single message in bytes.

  • None: No limit (default)
  • Some(size): Reject messages larger than size
§routing_id: Option<Bytes>

Socket identity / routing ID (ZMQ_ROUTING_ID / ZMQ_IDENTITY)

Identity for ROUTER addressing. If None, a random UUID is generated.

  • Default: None (auto-generate)
  • Custom: Set for stable identity across reconnections
§connect_routing_id: Option<Bytes>

Connect routing ID (ZMQ_CONNECT_ROUTING_ID)

Identity to assign to the next outgoing connection. Used by ROUTER sockets to assign a specific identity to a peer.

  • Default: None (auto-generate)
  • Custom: Assign explicit identity to next connection
  • Consumed after each connect operation
§router_mandatory: bool

ROUTER mandatory mode (ZMQ_ROUTER_MANDATORY)

  • false (default): Silently drop messages to unknown peers
  • true: Return error when sending to unknown peer
§router_handover: bool

ROUTER handover mode (ZMQ_ROUTER_HANDOVER)

  • false (default): Disconnect old peer when new peer with same identity connects
  • true: Hand over pending messages to new peer with same identity
§probe_router: bool

Probe ROUTER on connect (ZMQ_PROBE_ROUTER)

  • false (default): Normal operation
  • true: Send empty message on connect to probe ROUTER identity
§xpub_verbose: bool

XPUB verbose mode (ZMQ_XPUB_VERBOSE)

  • false (default): Only report new subscriptions
  • true: Report all subscription messages (including duplicates)
§xpub_manual: bool

XPUB manual mode (ZMQ_XPUB_MANUAL)

  • false (default): Automatic subscription management
  • true: Manual subscription control via send()
§xpub_welcome_msg: Option<Bytes>

XPUB welcome message (ZMQ_XPUB_WELCOME_MSG)

Message to send to new subscribers on connection. Useful for last value cache (LVC) patterns.

§xsub_verbose_unsubs: bool

XSUB verbose unsubscribe (ZMQ_XSUB_VERBOSE_UNSUBSCRIBE)

  • false (default): Don’t send explicit unsubscribe messages
  • true: Send unsubscribe messages upstream
§conflate: bool

Conflate messages (ZMQ_CONFLATE)

  • false (default): Queue all messages
  • true: Keep only last message (overwrite queue)
§tcp_keepalive: i32

TCP keepalive (ZMQ_TCP_KEEPALIVE)

  • -1 (default): Use OS default
  • 0: Disable TCP keepalive
  • 1: Enable TCP keepalive
§tcp_keepalive_cnt: i32

TCP keepalive count (ZMQ_TCP_KEEPALIVE_CNT)

Number of keepalive probes before considering connection dead.

  • -1 (default): Use OS default
  • > 0: Number of probes
§tcp_keepalive_idle: i32

TCP keepalive idle (ZMQ_TCP_KEEPALIVE_IDLE)

Time in seconds before starting keepalive probes.

  • -1 (default): Use OS default
  • > 0: Idle time in seconds
§tcp_keepalive_intvl: i32

TCP keepalive interval (ZMQ_TCP_KEEPALIVE_INTVL)

Time in seconds between keepalive probes.

  • -1 (default): Use OS default
  • > 0: Interval in seconds
§req_correlate: bool

REQ correlate mode (ZMQ_REQ_CORRELATE)

Match replies to requests using message envelope.

  • false (default): Accept any reply
  • true: Match reply envelope to request
§req_relaxed: bool

REQ relaxed mode (ZMQ_REQ_RELAXED)

Allow multiple outstanding requests without strict alternation.

  • false (default): Strict send-recv-send-recv pattern
  • true: Allow send-send-recv-recv pattern
§rate: i32

Multicast rate in kilobits per second (ZMQ_RATE)

Maximum send or receive data rate for multicast transports (PGM/EPGM).

  • Default: 100 kbps
§recovery_ivl: Duration

Multicast recovery interval (ZMQ_RECOVERY_IVL)

Maximum time to recover lost messages on multicast transports.

  • Default: 10 seconds
§sndbuf: i32

OS-level send buffer size (ZMQ_SNDBUF)

Size of kernel send buffer. 0 = OS default.

  • Default: 0 (use OS default)
§rcvbuf: i32

OS-level receive buffer size (ZMQ_RCVBUF)

Size of kernel receive buffer. 0 = OS default.

  • Default: 0 (use OS default)
§multicast_hops: i32

Multicast TTL (ZMQ_MULTICAST_HOPS)

Time-to-live for multicast packets.

  • Default: 1 (local network only)
§tos: i32

IP Type of Service (ZMQ_TOS)

Sets the ToS field in IP headers for QoS.

  • Default: 0 (normal service)
§multicast_maxtpdu: i32

Maximum multicast transmission unit (ZMQ_MULTICAST_MAXTPDU)

Maximum transport data unit for multicast.

  • Default: 1500 bytes
§ipv6: bool

IPv6 support (ZMQ_IPV6)

Enable IPv6 on socket.

  • false (default): IPv4 only
  • true: IPv6 support enabled
§bind_to_device: Option<String>

Bind to device (ZMQ_BINDTODEVICE)

Bind socket to specific network interface (Linux only).

  • Default: None (bind to all interfaces)
§plain_server: bool

PLAIN server mode (ZMQ_PLAIN_SERVER)

Enable PLAIN authentication as server.

  • false (default): Client mode
  • true: Server mode (validate credentials)
§plain_username: Option<String>

PLAIN username (ZMQ_PLAIN_USERNAME)

Username for PLAIN authentication (client side).

  • Default: None (no authentication)
§plain_password: Option<String>

PLAIN password (ZMQ_PLAIN_PASSWORD)

Password for PLAIN authentication (client side).

  • Default: None (no authentication)
§curve_server: bool

CURVE server mode (ZMQ_CURVE_SERVER)

Enable CURVE encryption as server.

  • false (default): Client mode
  • true: Server mode (provide server key)
§curve_publickey: Option<[u8; 32]>

CURVE public key (ZMQ_CURVE_PUBLICKEY)

Local public key for CURVE (32 bytes).

  • Default: None (no encryption)
§curve_secretkey: Option<[u8; 32]>

CURVE secret key (ZMQ_CURVE_SECRETKEY)

Local secret key for CURVE (32 bytes).

  • Default: None (no encryption)
§curve_serverkey: Option<[u8; 32]>

CURVE server key (ZMQ_CURVE_SERVERKEY)

Server’s public key for CURVE client (32 bytes).

  • Default: None (no encryption)
  • Client must set this to verify server identity
§zap_domain: String

ZAP domain (ZMQ_ZAP_DOMAIN)

Security domain for ZAP authentication.

  • Default: “” (global domain)
§subscriptions: Vec<Bytes>

Subscriptions (ZMQ_SUBSCRIBE)

Subscription filters for SUB/XSUB sockets.

  • Empty vec: No subscriptions (default) - won’t receive any messages
  • vec![b““] or vec![Bytes::new()]: Subscribe to all messages
  • vec![b“topic1“, b“topic2“]: Subscribe to specific topics

Note: SUB sockets MUST subscribe to at least one topic to receive messages.

§unsubscriptions: Vec<Bytes>

Unsubscriptions (ZMQ_UNSUBSCRIBE)

Subscription filters to remove for SUB/XSUB sockets. Applied after subscriptions during socket configuration.

§max_reconnect_attempts: Option<u32>

Maximum reconnection attempts (ZMQ_RECONNECT_STOP)

Maximum number of times to attempt reconnection after a disconnect.

  • None: Retry indefinitely (default, matches libzmq behaviour)
  • Some(n): Give up and return NotConnected after n attempts
§heartbeat_ivl: Option<Duration>

ZMTP heartbeat interval (ZMQ_HEARTBEAT_IVL = 75)

How often to send PING heartbeat commands on an otherwise idle connection.

  • None: Disabled (default)
  • Some(dur): Send PING every dur of inactivity
§heartbeat_ttl: Option<Duration>

ZMTP heartbeat TTL (ZMQ_HEARTBEAT_TTL = 76)

Time-to-live for the remote peer’s heartbeat (sent in PING command). The remote will disconnect if it doesn’t receive a heartbeat within this interval.

  • None: Use heartbeat_ivl (default)
  • Some(dur): Override TTL sent to peer
§heartbeat_timeout: Option<Duration>

ZMTP heartbeat timeout (ZMQ_HEARTBEAT_TIMEOUT = 77)

How long to wait for a PONG reply before considering the connection dead.

  • None: Use heartbeat_ivl (default)
  • Some(dur): Custom timeout (recommended: 2–5× heartbeat_ivl)
§router_raw: bool

ROUTER raw mode (ZMQ_ROUTER_RAW = 41)

Put ROUTER socket into raw mode (no ZMTP handshake, acts like STREAM).

  • false (default): Normal ZMTP routing
  • true: Raw TCP bridging mode
§stream_notify: bool

STREAM connect/disconnect notifications (ZMQ_STREAM_NOTIFY = 73)

Send empty notification frames on connect and disconnect.

  • true (default): Send notification frames
  • false: Suppress notification frames
§xpub_nodrop: bool

XPUB no-drop mode (ZMQ_XPUB_NODROP = 69)

  • false (default): Drop messages silently when HWM is reached
  • true: Return error (EAGAIN) instead of dropping
§invert_matching: bool

Invert topic matching (ZMQ_INVERT_MATCHING = 74)

Invert the subscription filter logic for PUB/SUB and XPUB/XSUB.

  • false (default): Deliver messages matching subscriptions
  • true: Deliver messages NOT matching any subscription

Implementations§

Source§

impl SocketOptions

Source

pub fn new() -> SocketOptions

Create new socket options with default values (8KB buffers).

Source

pub fn small() -> SocketOptions

Create socket options optimized for small messages (< 1KB).

Sets 4KB buffers, suitable for low-latency request-reply patterns.

§Examples
use monocoque_core::options::SocketOptions;

let opts = SocketOptions::small();  // 4KB buffers for REQ/REP
Source

pub fn large() -> SocketOptions

Create socket options optimized for large messages (> 8KB).

Sets 16KB buffers, suitable for high-throughput async patterns.

§Examples
use monocoque_core::options::SocketOptions;

let opts = SocketOptions::large();  // 16KB buffers for DEALER/ROUTER
Source

pub const fn with_recv_timeout(self, timeout: Duration) -> SocketOptions

Set receive timeout.

§Examples
use monocoque_core::options::SocketOptions;
use std::time::Duration;

// Non-blocking receive
let opts = SocketOptions::new().with_recv_timeout(Duration::ZERO);

// 5 second timeout
let opts = SocketOptions::new().with_recv_timeout(Duration::from_secs(5));
Source

pub const fn with_send_timeout(self, timeout: Duration) -> SocketOptions

Set send timeout.

Source

pub const fn with_handshake_timeout(self, timeout: Duration) -> SocketOptions

Set handshake timeout.

Source

pub const fn with_linger(self, linger: Option<Duration>) -> SocketOptions

Set linger timeout.

Source

pub const fn with_reconnect_ivl(self, ivl: Duration) -> SocketOptions

Set reconnection interval.

Source

pub const fn with_reconnect_ivl_max(self, max: Duration) -> SocketOptions

Set maximum reconnection interval for exponential backoff.

Source

pub const fn with_max_reconnect_attempts( self, max: Option<u32>, ) -> SocketOptions

Set maximum number of reconnection attempts.

None retries indefinitely (default); Some(n) gives up after n attempts.

Source

pub const fn with_connect_timeout(self, timeout: Duration) -> SocketOptions

Set connection timeout.

Source

pub const fn with_heartbeat_ivl(self, ivl: Duration) -> SocketOptions

Set heartbeat interval (ZMQ_HEARTBEAT_IVL).

Source

pub const fn with_heartbeat_ttl(self, ttl: Duration) -> SocketOptions

Set heartbeat TTL (ZMQ_HEARTBEAT_TTL).

Source

pub const fn with_heartbeat_timeout(self, timeout: Duration) -> SocketOptions

Set heartbeat timeout (ZMQ_HEARTBEAT_TIMEOUT).

Source

pub const fn with_router_raw(self, raw: bool) -> SocketOptions

Enable or disable ROUTER raw mode (ZMQ_ROUTER_RAW).

Source

pub const fn with_stream_notify(self, notify: bool) -> SocketOptions

Enable or disable STREAM connect/disconnect notifications (ZMQ_STREAM_NOTIFY).

Source

pub const fn with_xpub_nodrop(self, nodrop: bool) -> SocketOptions

Enable XPUB no-drop mode (ZMQ_XPUB_NODROP).

Source

pub const fn with_invert_matching(self, invert: bool) -> SocketOptions

Enable inverted topic matching (ZMQ_INVERT_MATCHING).

Source

pub const fn with_recv_hwm(self, hwm: usize) -> SocketOptions

Set receive high water mark.

Source

pub const fn with_send_hwm(self, hwm: usize) -> SocketOptions

Set send high water mark.

Source

pub const fn with_immediate(self, immediate: bool) -> SocketOptions

Enable or disable immediate mode.

Source

pub const fn with_max_msg_size(self, size: Option<usize>) -> SocketOptions

Set maximum message size.

Source

pub const fn with_read_buffer_size(self, size: usize) -> SocketOptions

Set read buffer size.

§Examples
use monocoque_core::options::SocketOptions;

// Small buffers for low latency
let opts = SocketOptions::new().with_read_buffer_size(4096);

// Large buffers for throughput
let opts = SocketOptions::new().with_read_buffer_size(16384);
Source

pub const fn with_write_buffer_size(self, size: usize) -> SocketOptions

Set write buffer size.

Source

pub const fn with_buffer_sizes( self, read_size: usize, write_size: usize, ) -> SocketOptions

Set both read and write buffer sizes (convenience method).

§Examples
use monocoque_core::options::SocketOptions;

// Small buffers for both
let opts = SocketOptions::new().with_buffer_sizes(4096, 4096);
Source

pub fn with_routing_id(self, id: Bytes) -> SocketOptions

Set socket routing ID / identity.

§Examples
use monocoque_core::options::SocketOptions;
use bytes::Bytes;

let opts = SocketOptions::new()
    .with_routing_id(Bytes::from_static(b"worker-01"));
Source

pub fn with_connect_routing_id(self, id: Bytes) -> SocketOptions

Set connect routing ID for the next connection.

This option is consumed after each connect operation and must be set again for subsequent connections.

§Examples
use monocoque_core::options::SocketOptions;
use bytes::Bytes;

let opts = SocketOptions::new()
    .with_connect_routing_id(Bytes::from_static(b"client-001"));
Source

pub const fn with_router_mandatory(self, enabled: bool) -> SocketOptions

Enable ROUTER mandatory mode.

Source

pub const fn with_router_handover(self, enabled: bool) -> SocketOptions

Enable ROUTER handover mode.

Source

pub const fn with_probe_router(self, enabled: bool) -> SocketOptions

Enable ROUTER probe on connect.

Source

pub const fn with_xpub_verbose(self, enabled: bool) -> SocketOptions

Enable XPUB verbose mode.

Source

pub const fn with_xpub_manual(self, enabled: bool) -> SocketOptions

Enable XPUB manual mode.

Source

pub fn with_xpub_welcome_msg(self, msg: Bytes) -> SocketOptions

Set XPUB welcome message.

Source

pub const fn with_xsub_verbose_unsubs(self, enabled: bool) -> SocketOptions

Enable XSUB verbose unsubscribe.

Source

pub const fn with_conflate(self, enabled: bool) -> SocketOptions

Enable message conflation (keep only last message).

Source

pub const fn with_tcp_keepalive(self, mode: i32) -> SocketOptions

Set TCP keepalive mode.

§Arguments
  • mode - -1 for OS default, 0 to disable, 1 to enable
Source

pub const fn with_tcp_keepalive_cnt(self, count: i32) -> SocketOptions

Set TCP keepalive count (number of probes before timeout).

§Arguments
  • count - -1 for OS default, > 0 for specific count
Source

pub const fn with_tcp_keepalive_idle(self, seconds: i32) -> SocketOptions

Set TCP keepalive idle time (seconds before first probe).

§Arguments
  • seconds - -1 for OS default, > 0 for specific idle time
Source

pub const fn with_tcp_keepalive_intvl(self, seconds: i32) -> SocketOptions

Set TCP keepalive interval (seconds between probes).

§Arguments
  • seconds - -1 for OS default, > 0 for specific interval
Source

pub const fn with_req_correlate(self, enabled: bool) -> SocketOptions

Enable REQ correlation mode (match replies to requests).

Source

pub const fn with_req_relaxed(self, enabled: bool) -> SocketOptions

Enable REQ relaxed mode (allow multiple outstanding requests).

Source

pub const fn with_rate(self, rate: i32) -> SocketOptions

Set multicast rate (ZMQ_RATE).

Source

pub const fn with_recovery_ivl(self, interval: Duration) -> SocketOptions

Set multicast recovery interval (ZMQ_RECOVERY_IVL).

Source

pub const fn with_sndbuf(self, size: i32) -> SocketOptions

Set OS send buffer size (ZMQ_SNDBUF).

Source

pub const fn with_rcvbuf(self, size: i32) -> SocketOptions

Set OS receive buffer size (ZMQ_RCVBUF).

Source

pub const fn with_multicast_hops(self, hops: i32) -> SocketOptions

Set multicast TTL/hops (ZMQ_MULTICAST_HOPS).

Source

pub const fn with_tos(self, tos: i32) -> SocketOptions

Set IP Type of Service (ZMQ_TOS).

Source

pub const fn with_multicast_maxtpdu(self, mtu: i32) -> SocketOptions

Set multicast maximum TPU (ZMQ_MULTICAST_MAXTPDU).

Source

pub const fn with_ipv6(self, enabled: bool) -> SocketOptions

Enable IPv6 support (ZMQ_IPV6).

Source

pub fn with_bind_to_device(self, device: impl Into<String>) -> SocketOptions

Bind to specific device (ZMQ_BINDTODEVICE) - Linux only.

Source

pub const fn with_plain_server(self, enabled: bool) -> SocketOptions

Enable PLAIN server mode.

§Examples
use monocoque_core::options::SocketOptions;

let opts = SocketOptions::new().with_plain_server(true);
Source

pub fn with_plain_credentials( self, username: impl Into<String>, password: impl Into<String>, ) -> SocketOptions

Set PLAIN client credentials.

§Examples
use monocoque_core::options::SocketOptions;

let opts = SocketOptions::new()
    .with_plain_credentials("admin", "secret123");
Source

pub const fn with_curve_server(self, enabled: bool) -> SocketOptions

Enable CURVE server mode.

§Examples
use monocoque_core::options::SocketOptions;

let opts = SocketOptions::new().with_curve_server(true);
Source

pub const fn with_curve_keypair( self, publickey: [u8; 32], secretkey: [u8; 32], ) -> SocketOptions

Set CURVE client keys (public + secret).

§Examples
use monocoque_core::options::SocketOptions;

let public = [0u8; 32];  // Replace with actual key
let secret = [0u8; 32];  // Replace with actual key
let opts = SocketOptions::new().with_curve_keypair(public, secret);
Source

pub const fn with_curve_serverkey(self, serverkey: [u8; 32]) -> SocketOptions

Set CURVE server public key (for client).

§Examples
use monocoque_core::options::SocketOptions;

let server_key = [0u8; 32];  // Server's public key
let opts = SocketOptions::new().with_curve_serverkey(server_key);
Source

pub fn with_zap_domain(self, domain: impl Into<String>) -> SocketOptions

Set ZAP domain for authentication.

§Examples
use monocoque_core::options::SocketOptions;

let opts = SocketOptions::new().with_zap_domain("production");
Source

pub fn with_subscribe(self, filter: Bytes) -> SocketOptions

Add a subscription filter for SUB/XSUB sockets (ZMQ_SUBSCRIBE).

SUB sockets MUST subscribe to at least one topic to receive messages. An empty filter (b““ or Bytes::new()) subscribes to all messages.

§Examples
use monocoque_core::options::SocketOptions;
use bytes::Bytes;

// Subscribe to all messages
let opts = SocketOptions::new().with_subscribe(Bytes::new());

// Subscribe to specific topics
let opts = SocketOptions::new()
    .with_subscribe(Bytes::from("weather."))
    .with_subscribe(Bytes::from("stocks."));
Source

pub fn with_subscriptions(self, filters: Vec<Bytes>) -> SocketOptions

Add multiple subscription filters for SUB/XSUB sockets.

Convenience method to subscribe to multiple topics at once.

§Examples
use monocoque_core::options::SocketOptions;
use bytes::Bytes;

let opts = SocketOptions::new()
    .with_subscriptions(vec![
        Bytes::from("weather."),
        Bytes::from("stocks."),
    ]);
Source

pub fn with_unsubscribe(self, filter: Bytes) -> SocketOptions

Add an unsubscription filter for SUB/XSUB sockets (ZMQ_UNSUBSCRIBE).

Removes a previously added subscription filter.

§Examples
use monocoque_core::options::SocketOptions;
use bytes::Bytes;

let opts = SocketOptions::new()
    .with_subscribe(Bytes::new())  // Subscribe to all
    .with_unsubscribe(Bytes::from("admin.")); // Except admin topics
Source

pub const fn is_recv_nonblocking(&self) -> bool

Check if receive operation should be non-blocking.

Source

pub const fn is_send_nonblocking(&self) -> bool

Check if send operation should be non-blocking.

Source

pub fn validate_router_identity(id: &[u8]) -> Result<(), Error>

Validate routing ID for use with ROUTER sockets.

ROUTER socket identities must:

  • Be 1-255 bytes long
  • Not start with null byte (0x00) which is reserved for auto-generated IDs
Source

pub fn validate_routing_id(id: &[u8]) -> Result<(), Error>

Validate general routing ID (for DEALER, REQ, REP).

Less strict than ROUTER identities - allows null prefix.

Source

pub fn next_reconnect_ivl(&self, attempt: u32) -> Duration

Get the current reconnection interval with exponential backoff.

Returns the interval to use, considering exponential backoff and the maximum interval setting.

Trait Implementations§

Source§

impl Clone for SocketOptions

Source§

fn clone(&self) -> SocketOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SocketOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SocketOptions

Source§

fn default() -> SocketOptions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more