acta-maker-sdk 0.8.2

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

use crate::ws::types::ClientMessage;

use super::ManagedCommand;

pub struct ManagedWsTestPeer {
    commands: mpsc::Receiver<ManagedCommand>,
}

impl ManagedWsTestPeer {
    #[cfg(not(test))]
    pub(super) const fn new(commands: mpsc::Receiver<ManagedCommand>) -> Self {
        Self { commands }
    }

    pub async fn acknowledge_next_send(&mut self) -> Option<ClientMessage> {
        match self.commands.recv().await? {
            ManagedCommand::Send { message, tx, .. } => {
                let _ = tx.send(Ok(()));
                serde_json::from_str(message.as_str()).ok()
            }
            _ => None,
        }
    }
}