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-throughputFields§
§read_buffer_size: usizeRead 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: usizeWrite 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: DurationHandshake timeout (ZMQ_HANDSHAKE_IVL)
Maximum time to complete ZMTP handshake after connection.
- Default: 30 seconds
- Set to
Duration::ZEROto 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 messagesSome(Duration::ZERO): Same as NoneSome(duration): Wait up to duration for messages to be sent
reconnect_ivl: DurationReconnect interval (ZMQ_RECONNECT_IVL)
Initial reconnection delay after connection loss.
- Default: 100ms
- Use with
reconnect_ivl_maxfor exponential backoff
reconnect_ivl_max: DurationMaximum reconnect interval (ZMQ_RECONNECT_IVL_MAX)
Maximum reconnection delay for exponential backoff.
- Default: 0 (no maximum, use
reconnect_ivlalways) - When > 0: Doubles
reconnect_ivlup to this value
connect_timeout: DurationConnection timeout (ZMQ_CONNECT_TIMEOUT)
Maximum time to wait for TCP connection to complete.
- Default: 0 (use OS default)
recv_hwm: usizeHigh 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: usizeHigh 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: boolEnable immediate connect mode (ZMQ_IMMEDIATE)
false(default): Queue messages while connectingtrue: 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: boolROUTER mandatory mode (ZMQ_ROUTER_MANDATORY)
false(default): Silently drop messages to unknown peerstrue: Return error when sending to unknown peer
router_handover: boolROUTER handover mode (ZMQ_ROUTER_HANDOVER)
false(default): Disconnect old peer when new peer with same identity connectstrue: Hand over pending messages to new peer with same identity
probe_router: boolProbe ROUTER on connect (ZMQ_PROBE_ROUTER)
false(default): Normal operationtrue: Send empty message on connect to probe ROUTER identity
xpub_verbose: boolXPUB verbose mode (ZMQ_XPUB_VERBOSE)
false(default): Only report new subscriptionstrue: Report all subscription messages (including duplicates)
xpub_manual: boolXPUB manual mode (ZMQ_XPUB_MANUAL)
false(default): Automatic subscription managementtrue: Manual subscription control viasend()
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: boolXSUB verbose unsubscribe (ZMQ_XSUB_VERBOSE_UNSUBSCRIBE)
false(default): Don’t send explicit unsubscribe messagestrue: Send unsubscribe messages upstream
conflate: boolConflate messages (ZMQ_CONFLATE)
false(default): Queue all messagestrue: Keep only last message (overwrite queue)
tcp_keepalive: i32TCP keepalive (ZMQ_TCP_KEEPALIVE)
-1(default): Use OS default0: Disable TCP keepalive1: Enable TCP keepalive
tcp_keepalive_cnt: i32TCP 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: i32TCP 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: i32TCP keepalive interval (ZMQ_TCP_KEEPALIVE_INTVL)
Time in seconds between keepalive probes.
-1(default): Use OS default> 0: Interval in seconds
req_correlate: boolREQ correlate mode (ZMQ_REQ_CORRELATE)
Match replies to requests using message envelope.
false(default): Accept any replytrue: Match reply envelope to request
req_relaxed: boolREQ relaxed mode (ZMQ_REQ_RELAXED)
Allow multiple outstanding requests without strict alternation.
false(default): Strict send-recv-send-recv patterntrue: Allow send-send-recv-recv pattern
rate: i32Multicast rate in kilobits per second (ZMQ_RATE)
Maximum send or receive data rate for multicast transports (PGM/EPGM).
- Default: 100 kbps
recovery_ivl: DurationMulticast recovery interval (ZMQ_RECOVERY_IVL)
Maximum time to recover lost messages on multicast transports.
- Default: 10 seconds
sndbuf: i32OS-level send buffer size (ZMQ_SNDBUF)
Size of kernel send buffer. 0 = OS default.
- Default: 0 (use OS default)
rcvbuf: i32OS-level receive buffer size (ZMQ_RCVBUF)
Size of kernel receive buffer. 0 = OS default.
- Default: 0 (use OS default)
multicast_hops: i32Multicast TTL (ZMQ_MULTICAST_HOPS)
Time-to-live for multicast packets.
- Default: 1 (local network only)
tos: i32IP Type of Service (ZMQ_TOS)
Sets the ToS field in IP headers for QoS.
- Default: 0 (normal service)
multicast_maxtpdu: i32Maximum multicast transmission unit (ZMQ_MULTICAST_MAXTPDU)
Maximum transport data unit for multicast.
- Default: 1500 bytes
ipv6: boolIPv6 support (ZMQ_IPV6)
Enable IPv6 on socket.
false(default): IPv4 onlytrue: 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: boolPLAIN server mode (ZMQ_PLAIN_SERVER)
Enable PLAIN authentication as server.
false(default): Client modetrue: 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: boolCURVE server mode (ZMQ_CURVE_SERVER)
Enable CURVE encryption as server.
false(default): Client modetrue: 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: StringZAP 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 returnNotConnectedafter 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 everydurof 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: Useheartbeat_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: Useheartbeat_ivl(default)Some(dur): Custom timeout (recommended: 2–5× heartbeat_ivl)
router_raw: boolROUTER raw mode (ZMQ_ROUTER_RAW = 41)
Put ROUTER socket into raw mode (no ZMTP handshake, acts like STREAM).
false(default): Normal ZMTP routingtrue: Raw TCP bridging mode
stream_notify: boolSTREAM connect/disconnect notifications (ZMQ_STREAM_NOTIFY = 73)
Send empty notification frames on connect and disconnect.
true(default): Send notification framesfalse: Suppress notification frames
xpub_nodrop: boolXPUB no-drop mode (ZMQ_XPUB_NODROP = 69)
false(default): Drop messages silently when HWM is reachedtrue: Return error (EAGAIN) instead of dropping
invert_matching: boolInvert topic matching (ZMQ_INVERT_MATCHING = 74)
Invert the subscription filter logic for PUB/SUB and XPUB/XSUB.
false(default): Deliver messages matching subscriptionstrue: Deliver messages NOT matching any subscription
Implementations§
Source§impl SocketOptions
impl SocketOptions
Sourcepub fn new() -> SocketOptions
pub fn new() -> SocketOptions
Create new socket options with default values (8KB buffers).
Sourcepub fn small() -> SocketOptions
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/REPSourcepub fn large() -> SocketOptions
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/ROUTERSourcepub const fn with_recv_timeout(self, timeout: Duration) -> SocketOptions
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));Sourcepub const fn with_send_timeout(self, timeout: Duration) -> SocketOptions
pub const fn with_send_timeout(self, timeout: Duration) -> SocketOptions
Set send timeout.
Sourcepub const fn with_handshake_timeout(self, timeout: Duration) -> SocketOptions
pub const fn with_handshake_timeout(self, timeout: Duration) -> SocketOptions
Set handshake timeout.
Sourcepub const fn with_linger(self, linger: Option<Duration>) -> SocketOptions
pub const fn with_linger(self, linger: Option<Duration>) -> SocketOptions
Set linger timeout.
Sourcepub const fn with_reconnect_ivl(self, ivl: Duration) -> SocketOptions
pub const fn with_reconnect_ivl(self, ivl: Duration) -> SocketOptions
Set reconnection interval.
Sourcepub const fn with_reconnect_ivl_max(self, max: Duration) -> SocketOptions
pub const fn with_reconnect_ivl_max(self, max: Duration) -> SocketOptions
Set maximum reconnection interval for exponential backoff.
Sourcepub const fn with_max_reconnect_attempts(
self,
max: Option<u32>,
) -> SocketOptions
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.
Sourcepub const fn with_connect_timeout(self, timeout: Duration) -> SocketOptions
pub const fn with_connect_timeout(self, timeout: Duration) -> SocketOptions
Set connection timeout.
Sourcepub const fn with_heartbeat_ivl(self, ivl: Duration) -> SocketOptions
pub const fn with_heartbeat_ivl(self, ivl: Duration) -> SocketOptions
Set heartbeat interval (ZMQ_HEARTBEAT_IVL).
Sourcepub const fn with_heartbeat_ttl(self, ttl: Duration) -> SocketOptions
pub const fn with_heartbeat_ttl(self, ttl: Duration) -> SocketOptions
Set heartbeat TTL (ZMQ_HEARTBEAT_TTL).
Sourcepub const fn with_heartbeat_timeout(self, timeout: Duration) -> SocketOptions
pub const fn with_heartbeat_timeout(self, timeout: Duration) -> SocketOptions
Set heartbeat timeout (ZMQ_HEARTBEAT_TIMEOUT).
Sourcepub const fn with_router_raw(self, raw: bool) -> SocketOptions
pub const fn with_router_raw(self, raw: bool) -> SocketOptions
Enable or disable ROUTER raw mode (ZMQ_ROUTER_RAW).
Sourcepub const fn with_stream_notify(self, notify: bool) -> SocketOptions
pub const fn with_stream_notify(self, notify: bool) -> SocketOptions
Enable or disable STREAM connect/disconnect notifications (ZMQ_STREAM_NOTIFY).
Sourcepub const fn with_xpub_nodrop(self, nodrop: bool) -> SocketOptions
pub const fn with_xpub_nodrop(self, nodrop: bool) -> SocketOptions
Enable XPUB no-drop mode (ZMQ_XPUB_NODROP).
Sourcepub const fn with_invert_matching(self, invert: bool) -> SocketOptions
pub const fn with_invert_matching(self, invert: bool) -> SocketOptions
Enable inverted topic matching (ZMQ_INVERT_MATCHING).
Sourcepub const fn with_recv_hwm(self, hwm: usize) -> SocketOptions
pub const fn with_recv_hwm(self, hwm: usize) -> SocketOptions
Set receive high water mark.
Sourcepub const fn with_send_hwm(self, hwm: usize) -> SocketOptions
pub const fn with_send_hwm(self, hwm: usize) -> SocketOptions
Set send high water mark.
Sourcepub const fn with_immediate(self, immediate: bool) -> SocketOptions
pub const fn with_immediate(self, immediate: bool) -> SocketOptions
Enable or disable immediate mode.
Sourcepub const fn with_max_msg_size(self, size: Option<usize>) -> SocketOptions
pub const fn with_max_msg_size(self, size: Option<usize>) -> SocketOptions
Set maximum message size.
Sourcepub const fn with_read_buffer_size(self, size: usize) -> SocketOptions
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);Sourcepub const fn with_write_buffer_size(self, size: usize) -> SocketOptions
pub const fn with_write_buffer_size(self, size: usize) -> SocketOptions
Set write buffer size.
Sourcepub const fn with_buffer_sizes(
self,
read_size: usize,
write_size: usize,
) -> SocketOptions
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);Sourcepub fn with_routing_id(self, id: Bytes) -> SocketOptions
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"));Sourcepub fn with_connect_routing_id(self, id: Bytes) -> SocketOptions
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"));Sourcepub const fn with_router_mandatory(self, enabled: bool) -> SocketOptions
pub const fn with_router_mandatory(self, enabled: bool) -> SocketOptions
Enable ROUTER mandatory mode.
Sourcepub const fn with_router_handover(self, enabled: bool) -> SocketOptions
pub const fn with_router_handover(self, enabled: bool) -> SocketOptions
Enable ROUTER handover mode.
Sourcepub const fn with_probe_router(self, enabled: bool) -> SocketOptions
pub const fn with_probe_router(self, enabled: bool) -> SocketOptions
Enable ROUTER probe on connect.
Sourcepub const fn with_xpub_verbose(self, enabled: bool) -> SocketOptions
pub const fn with_xpub_verbose(self, enabled: bool) -> SocketOptions
Enable XPUB verbose mode.
Sourcepub const fn with_xpub_manual(self, enabled: bool) -> SocketOptions
pub const fn with_xpub_manual(self, enabled: bool) -> SocketOptions
Enable XPUB manual mode.
Sourcepub fn with_xpub_welcome_msg(self, msg: Bytes) -> SocketOptions
pub fn with_xpub_welcome_msg(self, msg: Bytes) -> SocketOptions
Set XPUB welcome message.
Sourcepub const fn with_xsub_verbose_unsubs(self, enabled: bool) -> SocketOptions
pub const fn with_xsub_verbose_unsubs(self, enabled: bool) -> SocketOptions
Enable XSUB verbose unsubscribe.
Sourcepub const fn with_conflate(self, enabled: bool) -> SocketOptions
pub const fn with_conflate(self, enabled: bool) -> SocketOptions
Enable message conflation (keep only last message).
Sourcepub const fn with_tcp_keepalive(self, mode: i32) -> SocketOptions
pub const fn with_tcp_keepalive(self, mode: i32) -> SocketOptions
Sourcepub const fn with_tcp_keepalive_cnt(self, count: i32) -> SocketOptions
pub const fn with_tcp_keepalive_cnt(self, count: i32) -> SocketOptions
Set TCP keepalive count (number of probes before timeout).
§Arguments
count--1for OS default,> 0for specific count
Sourcepub const fn with_tcp_keepalive_idle(self, seconds: i32) -> SocketOptions
pub const fn with_tcp_keepalive_idle(self, seconds: i32) -> SocketOptions
Set TCP keepalive idle time (seconds before first probe).
§Arguments
seconds--1for OS default,> 0for specific idle time
Sourcepub const fn with_tcp_keepalive_intvl(self, seconds: i32) -> SocketOptions
pub const fn with_tcp_keepalive_intvl(self, seconds: i32) -> SocketOptions
Set TCP keepalive interval (seconds between probes).
§Arguments
seconds--1for OS default,> 0for specific interval
Sourcepub const fn with_req_correlate(self, enabled: bool) -> SocketOptions
pub const fn with_req_correlate(self, enabled: bool) -> SocketOptions
Enable REQ correlation mode (match replies to requests).
Sourcepub const fn with_req_relaxed(self, enabled: bool) -> SocketOptions
pub const fn with_req_relaxed(self, enabled: bool) -> SocketOptions
Enable REQ relaxed mode (allow multiple outstanding requests).
Sourcepub const fn with_rate(self, rate: i32) -> SocketOptions
pub const fn with_rate(self, rate: i32) -> SocketOptions
Set multicast rate (ZMQ_RATE).
Sourcepub const fn with_recovery_ivl(self, interval: Duration) -> SocketOptions
pub const fn with_recovery_ivl(self, interval: Duration) -> SocketOptions
Set multicast recovery interval (ZMQ_RECOVERY_IVL).
Sourcepub const fn with_sndbuf(self, size: i32) -> SocketOptions
pub const fn with_sndbuf(self, size: i32) -> SocketOptions
Set OS send buffer size (ZMQ_SNDBUF).
Sourcepub const fn with_rcvbuf(self, size: i32) -> SocketOptions
pub const fn with_rcvbuf(self, size: i32) -> SocketOptions
Set OS receive buffer size (ZMQ_RCVBUF).
Sourcepub const fn with_multicast_hops(self, hops: i32) -> SocketOptions
pub const fn with_multicast_hops(self, hops: i32) -> SocketOptions
Set multicast TTL/hops (ZMQ_MULTICAST_HOPS).
Sourcepub const fn with_tos(self, tos: i32) -> SocketOptions
pub const fn with_tos(self, tos: i32) -> SocketOptions
Set IP Type of Service (ZMQ_TOS).
Sourcepub const fn with_multicast_maxtpdu(self, mtu: i32) -> SocketOptions
pub const fn with_multicast_maxtpdu(self, mtu: i32) -> SocketOptions
Set multicast maximum TPU (ZMQ_MULTICAST_MAXTPDU).
Sourcepub const fn with_ipv6(self, enabled: bool) -> SocketOptions
pub const fn with_ipv6(self, enabled: bool) -> SocketOptions
Enable IPv6 support (ZMQ_IPV6).
Sourcepub fn with_bind_to_device(self, device: impl Into<String>) -> SocketOptions
pub fn with_bind_to_device(self, device: impl Into<String>) -> SocketOptions
Bind to specific device (ZMQ_BINDTODEVICE) - Linux only.
Sourcepub const fn with_plain_server(self, enabled: bool) -> SocketOptions
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);Sourcepub fn with_plain_credentials(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> SocketOptions
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");Sourcepub const fn with_curve_server(self, enabled: bool) -> SocketOptions
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);Sourcepub const fn with_curve_keypair(
self,
publickey: [u8; 32],
secretkey: [u8; 32],
) -> SocketOptions
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);Sourcepub const fn with_curve_serverkey(self, serverkey: [u8; 32]) -> SocketOptions
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);Sourcepub fn with_zap_domain(self, domain: impl Into<String>) -> SocketOptions
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");Sourcepub fn with_subscribe(self, filter: Bytes) -> SocketOptions
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."));Sourcepub fn with_subscriptions(self, filters: Vec<Bytes>) -> SocketOptions
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."),
]);Sourcepub fn with_unsubscribe(self, filter: Bytes) -> SocketOptions
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 topicsSourcepub const fn is_recv_nonblocking(&self) -> bool
pub const fn is_recv_nonblocking(&self) -> bool
Check if receive operation should be non-blocking.
Sourcepub const fn is_send_nonblocking(&self) -> bool
pub const fn is_send_nonblocking(&self) -> bool
Check if send operation should be non-blocking.
Sourcepub fn validate_router_identity(id: &[u8]) -> Result<(), Error>
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
Sourcepub fn validate_routing_id(id: &[u8]) -> Result<(), Error>
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.
Sourcepub fn next_reconnect_ivl(&self, attempt: u32) -> Duration
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
impl Clone for SocketOptions
Source§fn clone(&self) -> SocketOptions
fn clone(&self) -> SocketOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SocketOptions
impl Debug for SocketOptions
Source§impl Default for SocketOptions
impl Default for SocketOptions
Source§fn default() -> SocketOptions
fn default() -> SocketOptions
Auto Trait Implementations§
impl !Freeze for SocketOptions
impl RefUnwindSafe for SocketOptions
impl Send for SocketOptions
impl Sync for SocketOptions
impl Unpin for SocketOptions
impl UnsafeUnpin for SocketOptions
impl UnwindSafe for SocketOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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