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§
Sourcetype Provider: AssetInfoProvider
type Provider: AssetInfoProvider
The type of provider that this connector creates.
This should be a type that implements the AssetInfoProvider trait.
Required Methods§
Sourcefn 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,
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.