rustzmq2 0.1.0

A native async Rust implementation of ZeroMQ
Documentation
//! `SocketEvent` enum emitted by the monitor channel.

use crate::endpoint::Endpoint;
use crate::PeerIdentity;
use crate::ZmqError;

/// Event emitted by the socket monitor channel (see [`Socket::monitor`](crate::Socket::monitor)).
///
/// Event kinds match libzmq's `ZMQ_EVENT_*` constants —
/// see [`zmq_socket_monitor(3)`](https://libzmq.readthedocs.io/en/latest/zmq_socket_monitor.html).
///
/// `SocketEvent` is `#[non_exhaustive]`. New variants may be added in
/// minor releases — pattern matches must include a `_` arm.
///
/// # Example
///
/// ```rust,no_run
/// use rustzmq2::SocketEvent;
///
/// fn describe(ev: &SocketEvent) -> String {
///     match ev {
///         SocketEvent::Listening(ep)        => format!("listening on {ep}"),
///         SocketEvent::Accepted(ep, id)     => format!("accept {ep} id={id}"),
///         SocketEvent::Connected(ep, id)    => format!("connect {ep} id={id}"),
///         SocketEvent::Disconnected(id)     => format!("disconnect id={id}"),
///         SocketEvent::AcceptFailed(err)    => format!("accept failed: {err}"),
///         SocketEvent::OptionIgnoredOnTransport { option, endpoint } => {
///             format!("option `{option}` ignored on {endpoint}")
///         }
///         _ => "other".into(),
///     }
/// }
/// ```
#[non_exhaustive]
#[derive(Debug)]
pub enum SocketEvent {
    /// A connection to a remote peer was established.
    Connected(Endpoint, PeerIdentity),
    /// A connection attempt was delayed (e.g. peer not yet available).
    ConnectDelayed,
    /// A connection attempt is being retried after a delay.
    ConnectRetried,
    /// The socket is now listening on the given endpoint.
    Listening(Endpoint),
    /// An inbound connection was accepted.
    Accepted(Endpoint, PeerIdentity),
    /// An inbound connection attempt failed.
    AcceptFailed(ZmqError),
    /// A peer disconnected.
    Disconnected(PeerIdentity),
    /// An option set on this socket has no effect for the transport used by
    /// `endpoint`. Emitted once per (option, socket) pair when a bind or
    /// connect routes through a transport that doesn't honor the option
    /// (e.g. CURVE on inproc). See `SocketOptions::warn_inproc_ignored`.
    OptionIgnoredOnTransport {
        option: &'static str,
        endpoint: Endpoint,
    },
}