motorcortex-rust 0.5.0

Motorcortex Rust: a Rust client for the Motorcortex Core real-time control system (async + blocking).
Documentation
//! NNG pipe-event bridge.
//!
//! Pipe events are the way NNG tells us a connection came up or was
//! lost at the transport layer. We translate them into [`PipeEvent`]
//! values and hand them to whichever driver owns the connection, so
//! state transitions (`Connected` / `ConnectionLost` / …) fire at
//! the right time without the driver having to poll anything.

/// What the NNG pipe-event callback turns into, stripped of the C types.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PipeEvent {
    /// `NNG_PIPE_EV_ADD_POST` — a new pipe has finished attaching to
    /// the socket. For a client dialer this means "dial succeeded,
    /// the socket is usable".
    Added,
    /// `NNG_PIPE_EV_REM_POST` — a pipe has been removed from the
    /// socket. The transport dropped; NNG's own reconnect loop may
    /// re-dial (we configure it to) and fire `Added` again later.
    Removed,
}

/// Type-erased handler the driver installs when calling
/// `ConnectionManager::connect`. Invoked synchronously from an NNG
/// thread — don't block inside it. Mainly used to shove events into
/// an `mpsc::UnboundedSender<Cmd>` variant.
pub(crate) type PipeEventHandler =
    std::sync::Arc<dyn Fn(PipeEvent) + Send + Sync + 'static>;