AssetInfoProviderConnector

Trait AssetInfoProviderConnector 

Source
pub trait AssetInfoProviderConnector: Send + Sync {
    type Provider: AssetInfoProvider;
    type Error: Display;

    // Required method
    fn connect<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Provider, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for factory objects that can establish connections to WebSocket providers.

This trait separates the connection establishment logic from the provider itself, allowing for cleaner error handling and reconnection strategies. Implementors should handle the initial connection setup and return a provider that’s ready to subscribe to asset information.

Required Associated Types§

Source

type Provider: AssetInfoProvider

The type of provider that this connector creates.

This should be a type that implements the AssetInfoProvider trait.

Source

type Error: Display

The type returned in the event of a connection failure.

This should be a custom error type that implements the Display trait and captures all possible error conditions during connection.

Required Methods§

Source

fn connect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Provider, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Establishes a connection to the WebSocket and returns a provider.

This method should handle the initial WebSocket connection setup, including any authentication or handshaking required by the API.

§Errors

Returns a connector-specific error if the connection fails, such as when the API is unavailable, authentication fails, or the connection can’t be established for any other reason.

Implementors§