pub trait Subscriber {
    type SubResponse: Validator + DeserializeOwned;

    fn base_url() -> &'static str;
    fn build_subscription_meta(
        subscriptions: &[Subscription]
    ) -> Result<SubscriptionMeta, SocketError>; fn subscribe<'life0, 'async_trait>(
        subscriptions: &'life0 [Subscription]
    ) -> Pin<Box<dyn Future<Output = Result<(WebSocket, SubscriptionIds), SocketError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Send + 'async_trait
, { ... } fn validate<'life0, 'async_trait>(
        websocket: &'life0 mut WebSocket,
        expected_responses: usize
    ) -> Pin<Box<dyn Future<Output = Result<(), SocketError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Send + 'async_trait
, { ... } fn subscription_timeout() -> Duration { ... } }
Expand description

Trait that defines how a subscriber will establish a WebSocket connection with an exchange, and action Subscriptions. This must be implemented when integrating a new exchange.

Required Associated Types

Deserialisable type that this Subscriber expects to receive from the exchange in response to Subscription requests. Implements Validator in order to determine if the SubResponse communicates a successful outcome.

Required Methods

Returns the Base URL of the exchange to establish a connection with.

Uses the provided Barter Subscriptions to build exchange specific subscription payloads. Generates a SubscriptionIds Hashmap that is used by an ExchangeTransformer to identify the Barter Subscriptions associated with received messages.

Provided Methods

Initialises a WebSocket connection, actions the provided collection of Barter Subscriptions, and validates that the Subscription were accepted by the exchange.

Uses the provided WebSocket connection to consume Subscription responses and validate their outcomes.

Return the expected Duration in which the exchange will respond to all actioned WebSocket Subscription requests.

Default: 10 seconds

Implementors