Connector

Trait Connector 

Source
pub trait Connector
where Self: Clone + Default + Debug + for<'de> Deserialize<'de> + Serialize + Sized,
{ type Channel: AsRef<str>; type Market: AsRef<str>; type Subscriber: Subscriber; type SubValidator: SubscriptionValidator; type SubResponse: Validator + Debug + DeserializeOwned; const ID: ExchangeId; // Required methods fn url() -> Result<Url, SocketError>; fn requests( exchange_subs: Vec<ExchangeSub<Self::Channel, Self::Market>>, ) -> Vec<WsMessage> ; // Provided methods fn ping_interval() -> Option<PingInterval> { ... } fn expected_responses<InstrumentKey>(map: &Map<InstrumentKey>) -> usize { ... } fn subscription_timeout() -> Duration { ... } }
Expand description

Primary exchange abstraction. Defines how to translate Barter types into exchange specific types, as well as connecting, subscribing, and interacting with the exchange server.

§Notes

This must be implemented for a new exchange integration!

Required Associated Constants§

Source

const ID: ExchangeId

Unique identifier for the exchange server being connected with.

Required Associated Types§

Source

type Channel: AsRef<str>

Type that defines how to translate a Barter Subscription into an exchange specific channel to be subscribed to.

§Examples
Source

type Market: AsRef<str>

Type that defines how to translate a Barter Subscription into an exchange specific market that can be subscribed to.

§Examples
Source

type Subscriber: Subscriber

Subscriber type that establishes a connection with the exchange server, and actions Subscriptions over the socket.

Source

type SubValidator: SubscriptionValidator

SubscriptionValidator type that listens to responses from the exchange server and validates if the actioned Subscriptions were successful.

Source

type SubResponse: Validator + Debug + DeserializeOwned

Deserialisable type that the Self::SubValidator expects to receive from the exchange server in response to the Subscription Self::requests sent over the WebSocket. Implements Validator in order to determine if Self communicates a successful Subscription outcome.

Required Methods§

Source

fn url() -> Result<Url, SocketError>

Base Url of the exchange server being connected with.

Source

fn requests( exchange_subs: Vec<ExchangeSub<Self::Channel, Self::Market>>, ) -> Vec<WsMessage>

Defines how to translate a collection of ExchangeSubs into the WsMessage subscription payloads sent to the exchange server.

Provided Methods§

Source

fn ping_interval() -> Option<PingInterval>

Defines PingInterval of custom application-level WebSocket pings for the exchange server being connected with.

Defaults to None, meaning that no custom pings are sent.

Source

fn expected_responses<InstrumentKey>(map: &Map<InstrumentKey>) -> usize

Number of Subscription responses expected from the exchange server in responses to the requests send. Used to validate all Subscriptions were accepted.

Source

fn subscription_timeout() -> Duration

Expected Duration the SubscriptionValidator will wait to receive all success responses to actioned Subscription requests.

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§

Source§

impl Connector for Bitfinex

Source§

impl Connector for Bitmex

Source§

impl Connector for Coinbase

Source§

impl Connector for Kraken

Source§

impl Connector for Okx

Source§

impl<Server> Connector for Binance<Server>
where Server: ExchangeServer,

Source§

impl<Server> Connector for Bybit<Server>
where Server: ExchangeServer,

Source§

impl<Server> Connector for Gateio<Server>
where Server: ExchangeServer,