use std::sync::Arc;
use exc_core::{types::instrument::InstrumentMeta, ExchangeError};
use rust_decimal::Decimal;
pub struct InstrumentsResponse {
kind: Kind,
}
impl InstrumentsResponse {
fn new(kind: Kind) -> Self {
Self { kind }
}
}
pub(crate) enum Kind {
Instrument(Option<Arc<InstrumentMeta<Decimal>>>),
}
impl From<Option<Arc<InstrumentMeta<Decimal>>>> for InstrumentsResponse {
fn from(res: Option<Arc<InstrumentMeta<Decimal>>>) -> Self {
Self::new(Kind::Instrument(res))
}
}
impl TryFrom<InstrumentsResponse> for Option<Arc<InstrumentMeta<Decimal>>> {
type Error = ExchangeError;
fn try_from(resp: InstrumentsResponse) -> Result<Self, Self::Error> {
let Kind::Instrument(resp) = resp.kind;
Ok(resp)
}
}