pub trait Connector{
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§
Sourceconst ID: ExchangeId
const ID: ExchangeId
Unique identifier for the exchange server being connected with.
Required Associated Types§
Sourcetype Channel: AsRef<str>
type Channel: AsRef<str>
Type that defines how to translate a Barter Subscription into an exchange specific
channel to be subscribed to.
§Examples
Sourcetype Market: AsRef<str>
type Market: AsRef<str>
Type that defines how to translate a Barter
Subscription into an exchange specific market that
can be subscribed to.
§Examples
Sourcetype Subscriber: Subscriber
type Subscriber: Subscriber
Subscriber type that establishes a connection with the exchange server, and actions
Subscriptions over the socket.
Sourcetype SubValidator: SubscriptionValidator
type SubValidator: SubscriptionValidator
SubscriptionValidator type that listens to responses from the exchange server and
validates if the actioned Subscriptions were
successful.
Sourcetype SubResponse: Validator + Debug + DeserializeOwned
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§
Provided Methods§
Sourcefn ping_interval() -> Option<PingInterval>
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.
Sourcefn expected_responses<InstrumentKey>(map: &Map<InstrumentKey>) -> usize
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.
Sourcefn subscription_timeout() -> Duration
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.