Push Client and Connection
connect
connectSignature
pub async fn connect(client: &Arc<PushClient>) -> Result<(), String>
Description
Opens TCP/TLS, authenticates with an RSA signature, starts read/write tasks, waits for server CONNECTED, then starts heartbeats.
Security warning: the current TLS configuration verifies neither the server certificate chain nor hostname, so it cannot authenticate the server and is vulnerable to man-in-the-middle attacks. Using an official endpoint or trusted network does not compensate for this omission; the SDK must implement complete certificate-chain and hostname verification.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| client | &Arc<PushClient> | Required | None |
Return
PushClient:Result<(), String>.
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::push::pb::{AssetData, OrderStatusData, PositionData, QuoteData};
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_connect(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = connect(push).await.map_err(|e| TigerError::Config(e))?;
Ok(())
}
Response example
No synchronous server response. Success means the connection flow completed and CONNECTED was received.
disconnect
disconnectSignature
pub fn disconnect(&self)
Description
Best-effort sends DISCONNECT, marks the client disconnected, stops background tasks, and invokes on_disconnect.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| none | - | Required by Rust type | None |
Return
PushClient:(). No response fields on success..
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_disconnect(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = push.disconnect();
Ok(())
}
Response example
No synchronous server response. This method only starts the local disconnect flow.
state
stateSignature
pub fn state(&self) -> ConnectionState
Description
Reads a connection-state snapshot: Disconnected, Connecting, or Connected.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| none | - | Required by Rust type | None |
Return
PushClient:ConnectionState.
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_state(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = push.state();
Ok(())
}
Response example
No synchronous server response. The return value is the local connection-state enum.
set_callbacks
set_callbacksSignature
pub fn set_callbacks(&self, cb: Callbacks)
Description
Atomically replaces the complete set of market, account, and connection callbacks; unset fields remain None.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| cb | Callbacks | Required by Rust type | None |
Return
()
Callbacks struct fields
| Callback field | Type signature | Description |
|---|---|---|
| on_quote/on_option/on_future | Option<Arc<dyn Fn(QuoteData) + Send + Sync>> | Stock, option, or futures quote changes, including BBO data |
| on_depth | Option<Arc<dyn Fn(QuoteDepthData) + Send + Sync>> | Depth-of-book data |
| on_tick | Option<Arc<dyn Fn(PushTradeTick) + Send + Sync>> | Trade ticks decoded by the SDK |
| on_full_tick | Option<Arc<dyn Fn(TickData) + Send + Sync>> | Full tick data |
| on_kline | Option<Arc<dyn Fn(KlineData) + Send + Sync>> | Minute K-line push |
| on_stock_top | Option<Arc<dyn Fn(StockTopData) + Send + Sync>> | Stock ranking push |
| on_option_top | Option<Arc<dyn Fn(OptionTopData) + Send + Sync>> | Option ranking push |
| on_asset | Option<Arc<dyn Fn(AssetData) + Send + Sync>> | Asset changes (full snapshot every 5s) |
| on_position | Option<Arc<dyn Fn(PositionData) + Send + Sync>> | Position changes (full snapshot every 5s) |
| on_order | Option<Arc<dyn Fn(OrderStatusData) + Send + Sync>> | Order status changes |
| on_transaction | Option<Arc<dyn Fn(OrderTransactionData) + Send + Sync>> | Order transaction details |
| on_connect/on_disconnect | Option<Arc<dyn Fn() + Send + Sync>> | Connected/disconnected notifications |
| on_error/on_kickout | Option<Arc<dyn Fn(String) + Send + Sync>> | Error/kickout notifications |
The dispatcher does have an on_quote_bbo fallback: it invokes that callback when the body is QuoteData but data_type is not Quote, Option, Future, or Cc. However, SubjectType::QuoteBbo currently maps to Quote, so a normal BBO subscription reaches on_quote, not the fallback; option and futures BBO reach on_option and on_future, respectively.
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_set_callbacks(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
use tigeropen::push::pb::{AssetData, OrderStatusData, PositionData, QuoteData};
let cb = Callbacks {
on_quote: Some(Arc::new(|data: QuoteData| {
println!("Quote change: symbol={}, latest_price={:?}", data.symbol, data.latest_price);
})),
on_order: Some(Arc::new(|data: OrderStatusData| {
println!("Order change: id={}, status={}", data.id, data.status);
})),
on_asset: Some(Arc::new(|data: AssetData| {
println!("Asset change: account={}, net_liquidation={}", data.account, data.net_liquidation);
})),
on_position: Some(Arc::new(|data: PositionData| {
println!("Position change: symbol={}, quantity={}", data.symbol, data.position_qty);
})),
on_connect: Some(Arc::new(|| {
println!("Connected");
})),
on_disconnect: Some(Arc::new(|| {
println!("Disconnected");
})),
..Callbacks::default()
};
push.set_callbacks(cb);
Ok(())
}
Response example
No synchronous server response. The callback set is replaced locally.
send_heartbeat
send_heartbeatSignature
pub fn send_heartbeat(&self) -> bool
Description
Builds and queues a Protobuf heartbeat request; success only means the local write channel accepted the frame.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| none | - | Required by Rust type | None |
Return
PushClient:bool. Returnsbool: whether the protocol frame entered the local send channel, not server acceptance..
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_send_heartbeat(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = push.send_heartbeat();
Ok(())
}
Response example
No synchronous server response. The returned bool only reports whether the heartbeat frame entered the local send channel.
handle_message
handle_messageSignature
pub fn handle_message(&self, data: &[u8])
Description
Decodes one varint32-length-prefixed Protobuf response and dispatches it by command and data type; intended mainly for tests or custom transports.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| data | &[u8] | Required by Rust type | None |
Return
PushClient:(). No response fields on success..
Usage
Normal applications do not call this method; the read task started by connect handles frames automatically. A custom transport must pass one complete varint32-length-prefixed Response frame; do not pass &[] or arbitrary bytes.
Response example
No synchronous server response. Decoded data is dispatched through registered callbacks.
Updated about 1 month ago
