rustrade_data/exchange/lse/channel.rs
1use super::Lse;
2use crate::{
3 Identifier,
4 subscription::{Subscription, book::OrderBooksL1, trade::PublicTrades},
5};
6
7/// The London Strategic Edge WebSocket channel.
8///
9/// # Why there is only one variant
10/// The provider publishes exactly one data frame — the tick — and it carries the same seven keys
11/// (`type`, `symbol`, `ts`, `price`, `bid`, `ask`, `volume`) on every dataset. There is no
12/// per-channel subscription: a subscribe names a symbol and nothing else
13/// (`{"action":"subscribe","symbol":"EUR/USD"}`), so both supported subscription kinds are decoded
14/// from the same frame.
15///
16/// The variant therefore exists because a [`Connector`](crate::exchange::Connector) must name a
17/// channel, not to select anything on the wire. It is not part of the
18/// [`SubscriptionId`](rustrade_integration::subscription::SubscriptionId) either: a tick is filed
19/// under its bare symbol, since a channel that never varies would only lengthen the identifier —
20/// see [`LseSubMapper`](super::mapper::LseSubMapper). Both kinds therefore share one identifier per
21/// symbol, which is unambiguous because each stream carries its own instrument map.
22#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
23pub enum LseChannel {
24 /// The tick frame — a price, a bid, an ask and a size for one symbol.
25 Tick,
26}
27
28impl AsRef<str> for LseChannel {
29 fn as_ref(&self) -> &str {
30 match self {
31 Self::Tick => "tick",
32 }
33 }
34}
35
36impl<Server, Instrument> Identifier<LseChannel>
37 for Subscription<Lse<Server>, Instrument, PublicTrades>
38{
39 fn id(&self) -> LseChannel {
40 LseChannel::Tick
41 }
42}
43
44impl<Server, Instrument> Identifier<LseChannel>
45 for Subscription<Lse<Server>, Instrument, OrderBooksL1>
46{
47 fn id(&self) -> LseChannel {
48 LseChannel::Tick
49 }
50}
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_channel_as_ref() {
58 assert_eq!(LseChannel::Tick.as_ref(), "tick");
59 }
60}