acta-maker-sdk 0.8.0

Rust SDK for the Acta options RFQ venue on Solana: maker and vault-operator WebSocket clients, order signing, chain builders
Documentation
use tokio::sync::watch;

/// Latest lifecycle state of a managed connection.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ManagedWsState {
    Connecting,
    Connected { connection_epoch: u64 },
    Authenticated { connection_epoch: u64 },
    Reconciled { connection_epoch: u64 },
    Ready { connection_epoch: u64 },
    Reconnecting { attempt: u64, delay_ms: u64 },
    Closed { reason: ManagedWsTerminationReason },
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ManagedWsTerminationReason {
    Requested,
    ReconnectLimitReached {
        limit: u64,
    },
    SessionReplaced,
    ProtocolVersionMismatch {
        requested_version: String,
        server_version: String,
        min_supported_version: String,
    },
    AuthenticationRejected {
        reason: String,
        message: Option<String>,
    },
    /// Session task panicked; respawn the client to reconnect.
    SessionPanicked,
    UnsupportedProtocolVersion,
}

#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum WaitUntilReadyError {
    #[error("managed websocket terminated: {0:?}")]
    Terminated(ManagedWsTerminationReason),
    #[error("managed websocket state channel closed")]
    StateChannelClosed,
}

pub(super) fn set_state(tx: &watch::Sender<ManagedWsState>, state: ManagedWsState) {
    tx.send_replace(state);
}