use tokio::sync::oneshot;
use crate::{api::receiver_api::RithmicResponse, error::RithmicError};
pub(crate) mod core;
pub mod history_plant;
pub mod order_plant;
pub mod pnl_plant;
pub mod subscription;
#[cfg(test)]
pub(crate) mod test_support;
pub mod ticker_plant;
pub(crate) mod trade_routes;
pub(crate) async fn await_first_response(
rx: oneshot::Receiver<Result<Vec<RithmicResponse>, RithmicError>>,
) -> Result<RithmicResponse, RithmicError> {
await_all_responses(rx)
.await?
.into_iter()
.next()
.ok_or(RithmicError::EmptyResponse)
}
pub(crate) async fn await_all_responses(
rx: oneshot::Receiver<Result<Vec<RithmicResponse>, RithmicError>>,
) -> Result<Vec<RithmicResponse>, RithmicError> {
rx.await.map_err(|_| RithmicError::ConnectionClosed)?
}