pub enum IncomingMessage {
Error(WsError),
MarketData(MarketDataMessage),
Limits(LimitsData),
Portfolio(WsPortfolioData),
OrderExecution(OrderMessage),
OrderTransaction(OrderMessage),
MarginalIndicators(MarginalIndicatorsData),
Unknown(String),
Reconnected,
}Expand description
One parsed inbound WebSocket frame.
A session sends these into the channel you gave it. The variant is chosen by the content of the
frame first (an error frame, a market data frame with responseType) and then by the channel the
session is on. A frame that fits nothing arrives as IncomingMessage::Unknown with its raw
text, so no data is lost silently.
§Examples
use brokapi_bcs_protocol::models::messages::IncomingMessage;
use brokapi_bcs_protocol::ws::client::BcsWsChannel;
use brokapi_bcs_protocol::ws::parse_incoming;
let frame = r#"{"responseType":"OrderBook","ticker":"SBER","classCode":"TQBR","bids":[],"asks":[]}"#;
match parse_incoming(frame, BcsWsChannel::MarketData) {
IncomingMessage::MarketData(_) => {}
other => panic!("unexpected: {other:?}"),
}Variants§
Error(WsError)
An error frame of the broker (type = "error").
MarketData(MarketDataMessage)
A market data frame: an answer to a subscription, or data.
Limits(LimitsData)
A snapshot of limits (limits channel).
Portfolio(WsPortfolioData)
A snapshot of the portfolio (portfolio channel).
OrderExecution(OrderMessage)
An order message from the execution or events channel.
OrderTransaction(OrderMessage)
An order message from the transaction channel (deprecated by the broker).
MarginalIndicators(MarginalIndicatorsData)
Margin indicators (margin channel).
Unknown(String)
A frame that could not be parsed into any of the above. It holds the raw text.
Reconnected
Not a frame of the broker: the session has just (re)connected, sent before it restores the
subscriptions. Only when the session was opened with WsOptions::announce_connects. The first
connect sends it too. A reader counts them: from the second on, the connection was lost and
everything that came before is not continued by what follows.
Trait Implementations§
Source§impl Clone for IncomingMessage
impl Clone for IncomingMessage
Source§fn clone(&self) -> IncomingMessage
fn clone(&self) -> IncomingMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more