Trait SubscriptionConverter

Source
pub trait SubscriptionConverter<T: Debug> {
    // Required methods
    fn convert(options: &SubscriptionOptions) -> T;
    fn create_trade_subscription(
        ticket: &str,
        symbols: SmallVec<[String; 8]>,
        is_snapshot_only: Option<bool>,
        is_realtime_only: Option<bool>,
        additional_params: Option<&[(&str, &str)]>,
    ) -> T;
    fn create_orderbook_subscription(
        ticket: &str,
        symbols: SmallVec<[String; 8]>,
        depth: Option<u32>,
        update_speed: Option<u64>,
        is_snapshot_only: Option<bool>,
        is_realtime_only: Option<bool>,
        additional_params: Option<&[(&str, &str)]>,
    ) -> T;
    fn create_ticker_subscription(
        ticket: &str,
        symbols: SmallVec<[String; 8]>,
        is_snapshot_only: Option<bool>,
        is_realtime_only: Option<bool>,
        additional_params: Option<&[(&str, &str)]>,
    ) -> T;
    fn create_kline_subscription(
        ticket: &str,
        symbols: SmallVec<[String; 8]>,
        interval: &str,
        is_snapshot_only: Option<bool>,
        is_realtime_only: Option<bool>,
        additional_params: Option<&[(&str, &str)]>,
    ) -> T;
}
Expand description

Generic trait for converting standardized subscription options to exchange-specific formats

This trait defines the interface that all exchange-specific subscription converters must implement to convert from the standardized SubscriptionOptions structure to the exchange’s native format.

Required Methods§

Source

fn convert(options: &SubscriptionOptions) -> T

Convert standardized SubscriptionOptions to exchange-specific format

This method must be implemented by each exchange to convert the common subscription options into a format that can be sent directly to the exchange’s WebSocket API.

§Arguments
  • options - The standardized subscription options
§Returns

An exchange-specific subscription message/request of type T

Source

fn create_trade_subscription( ticket: &str, symbols: SmallVec<[String; 8]>, is_snapshot_only: Option<bool>, is_realtime_only: Option<bool>, additional_params: Option<&[(&str, &str)]>, ) -> T

Create a trade subscription message for the specified symbols

§Arguments
  • ticket - A unique identifier for the subscription (correlation ID)
  • symbols - List of symbols to subscribe to
  • is_snapshot_only - Optional flag to only receive snapshot data
  • is_realtime_only - Optional flag to only receive real-time updates
  • additional_params - Optional additional parameters for the exchange
§Returns

An exchange-specific subscription message/request

Source

fn create_orderbook_subscription( ticket: &str, symbols: SmallVec<[String; 8]>, depth: Option<u32>, update_speed: Option<u64>, is_snapshot_only: Option<bool>, is_realtime_only: Option<bool>, additional_params: Option<&[(&str, &str)]>, ) -> T

Create an orderbook subscription message for the specified symbols

§Arguments
  • ticket - A unique identifier for the subscription (correlation ID)
  • symbols - List of symbols to subscribe to
  • depth - Optional depth level
  • update_speed - Optional update speed in milliseconds
  • is_snapshot_only - Optional flag to only receive snapshot data
  • is_realtime_only - Optional flag to only receive real-time updates
  • additional_params - Optional additional parameters for the exchange
§Returns

An exchange-specific subscription message/request

Source

fn create_ticker_subscription( ticket: &str, symbols: SmallVec<[String; 8]>, is_snapshot_only: Option<bool>, is_realtime_only: Option<bool>, additional_params: Option<&[(&str, &str)]>, ) -> T

Create a ticker subscription message for the specified symbols

§Arguments
  • ticket - A unique identifier for the subscription (correlation ID)
  • symbols - List of symbols to subscribe to
  • is_snapshot_only - Optional flag to only receive snapshot data
  • is_realtime_only - Optional flag to only receive real-time updates
  • additional_params - Optional additional parameters for the exchange
§Returns

An exchange-specific subscription message/request

Source

fn create_kline_subscription( ticket: &str, symbols: SmallVec<[String; 8]>, interval: &str, is_snapshot_only: Option<bool>, is_realtime_only: Option<bool>, additional_params: Option<&[(&str, &str)]>, ) -> T

Create a kline/candlestick subscription message for the specified symbols

§Arguments
  • ticket - A unique identifier for the subscription (correlation ID)
  • symbols - List of symbols to subscribe to
  • interval - Time interval (e.g., “1m”, “1h”, “1d”)
  • is_snapshot_only - Optional flag to only receive snapshot data
  • is_realtime_only - Optional flag to only receive real-time updates
  • additional_params - Optional additional parameters for the exchange
§Returns

An exchange-specific subscription message/request

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§