barter_data/exchange/gateio/spot/
mod.rs1use self::trade::GateioSpotTrade;
2use super::Gateio;
3use crate::{
4 ExchangeWsStream, NoInitialSnapshots,
5 exchange::{ExchangeServer, StreamSelector},
6 instrument::InstrumentData,
7 subscription::trade::PublicTrades,
8 transformer::stateless::StatelessTransformer,
9};
10use barter_instrument::exchange::ExchangeId;
11use barter_macro::{DeExchange, SerExchange};
12use std::fmt::Display;
13
14pub mod trade;
16
17pub const WEBSOCKET_BASE_URL_GATEIO_SPOT: &str = "wss://api.gateio.ws/ws/v4/";
21
22pub type GateioSpot = Gateio<GateioServerSpot>;
24
25#[derive(
27 Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, DeExchange, SerExchange,
28)]
29pub struct GateioServerSpot;
30
31impl ExchangeServer for GateioServerSpot {
32 const ID: ExchangeId = ExchangeId::GateioSpot;
33
34 fn websocket_url() -> &'static str {
35 WEBSOCKET_BASE_URL_GATEIO_SPOT
36 }
37}
38
39impl<Instrument> StreamSelector<Instrument, PublicTrades> for GateioSpot
40where
41 Instrument: InstrumentData,
42{
43 type SnapFetcher = NoInitialSnapshots;
44 type Stream = ExchangeWsStream<
45 StatelessTransformer<Self, Instrument::Key, PublicTrades, GateioSpotTrade>,
46 >;
47}
48
49impl Display for GateioSpot {
50 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51 write!(f, "GateioSpot")
52 }
53}