1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use super::Okx;
use crate::{subscription::Subscription, Identifier};
use barter_integration::model::InstrumentKind;
use serde::{Deserialize, Serialize};
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Deserialize, Serialize)]
pub struct OkxMarket(pub String);
impl<Kind> Identifier<OkxMarket> for Subscription<Okx, Kind> {
fn id(&self) -> OkxMarket {
OkxMarket(match self.instrument.kind {
InstrumentKind::Spot => {
format!("{}-{}", self.instrument.base, self.instrument.quote).to_uppercase()
}
InstrumentKind::FuturePerpetual => {
format!("{}-{}-SWAP", self.instrument.base, self.instrument.quote).to_uppercase()
}
})
}
}
impl AsRef<str> for OkxMarket {
fn as_ref(&self) -> &str {
&self.0
}
}