ctrader_rs/types.rs
1use futures_util::stream::SplitSink;
2use serde::{Deserialize, Serialize};
3use std::sync::Arc;
4use tokio::sync::Mutex;
5use tokio_tungstenite::{WebSocketStream, tungstenite::Message};
6
7/// CTrader Auth details
8/// * ctrader_client_id - CTrader Application Client ID
9/// * ctrader_client_secret - CTrader Application Secret
10/// * ctrader_redirect_url - Ctrader Application Redirect URL
11/// * ctrader_refresh_token - Ctrader Application Refresh Token
12#[derive(Debug, Serialize, Deserialize, Clone)]
13pub struct Auth {
14 pub ctrader_access_token: String,
15 pub ctrader_client_id: String,
16 pub ctrader_client_secret: String,
17 pub ctrader_redirect_url: String,
18 pub ctrader_refresh_token: String,
19}
20
21/// The CTrader client instance
22/// * auth - The Authorization information to use.
23/// * write_stream - The websocket stream to use to send to the websocket server.
24/// * read_stream - The websocket stream to use to receive messages from the websocket server.
25//
26//
27//
28
29//
30//
31#[derive(Debug, Clone)]
32pub struct CTraderClient {
33 pub auth: Auth,
34
35 pub ws_write: Arc<
36 Mutex<
37 SplitSink<
38 WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>,
39 Message,
40 >,
41 >,
42 >,
43}
44
45/// The representation of the response from the get token request.
46#[derive(Serialize, Deserialize)]
47pub struct TokenResponse;