pub trait DataSource:
Send
+ Sync
+ 'static {
// Required methods
fn run<'life0, 'async_trait>(
&'life0 self,
sink: Sender<Vec<MarketEvent>>,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn name(&self) -> &str;
}Expand description
A provider of normalized market events.
A data source is responsible for:
- Connecting to the underlying data feed (WebSocket, REST, file).
- Fetching/streaming raw data.
- Normalizing raw data into
MarketEventvariants. - Sending events to the supplied
sinkchannel.
The run method is the main execution loop. It runs until the feed is
exhausted, an unrecoverable error occurs, or the CancellationToken is
triggered.
Required Methods§
Sourcefn run<'life0, 'async_trait>(
&'life0 self,
sink: Sender<Vec<MarketEvent>>,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
sink: Sender<Vec<MarketEvent>>,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start streaming events.
The implementation sends Vec<MarketEvent> batches to the provided
async channel sender. The cancel token should be polled periodically
to support graceful shutdown.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".