barter_data/exchange/gateio/option/
mod.rs

1use crate::{
2    ExchangeWsStream, NoInitialSnapshots,
3    exchange::{
4        ExchangeServer, StreamSelector,
5        gateio::{Gateio, perpetual::trade::GateioFuturesTrades},
6    },
7    instrument::InstrumentData,
8    subscription::trade::PublicTrades,
9    transformer::stateless::StatelessTransformer,
10};
11use barter_instrument::exchange::ExchangeId;
12use std::fmt::Display;
13
14/// [`GateioOptions`] WebSocket server base url.
15///
16/// See docs: <https://www.gate.io/docs/developers/futures/ws/en/>
17pub const WEBSOCKET_BASE_URL_GATEIO_OPTIONS_USD: &str = "wss://op-ws.gateio.live/v4/ws";
18
19/// [`Gateio`] options exchange.
20pub type GateioOptions = Gateio<GateioServerOptions>;
21
22/// [`Gateio`] options [`ExchangeServer`].
23#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
24pub struct GateioServerOptions;
25
26impl ExchangeServer for GateioServerOptions {
27    const ID: ExchangeId = ExchangeId::GateioOptions;
28
29    fn websocket_url() -> &'static str {
30        WEBSOCKET_BASE_URL_GATEIO_OPTIONS_USD
31    }
32}
33
34impl<Instrument> StreamSelector<Instrument, PublicTrades> for GateioOptions
35where
36    Instrument: InstrumentData,
37{
38    type SnapFetcher = NoInitialSnapshots;
39    type Stream = ExchangeWsStream<
40        StatelessTransformer<Self, Instrument::Key, PublicTrades, GateioFuturesTrades>,
41    >;
42}
43
44impl Display for GateioOptions {
45    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46        write!(f, "GateioOptions")
47    }
48}