pub trait BatchSource: Send {
// Required methods
fn receive_batch<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<Vec<RecordBatch>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn identifier(&self) -> &str;
// Provided methods
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
A batch-oriented data source that produces Arrow RecordBatches.
§Lifecycle
start()— initialize (connect, subscribe, bind)receive_batch()— pull data in a loopclose()— release resources (unsubscribe, close connections)
close() must be idempotent — safe to call multiple times, even before start().
§Empty vs EOF
- Return
Ok(vec![])when no data is currently available (caller should retry). - Return
Err(SourceReason::EOF.into())when the stream has ended.
Required Methods§
Sourcefn receive_batch<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<Vec<RecordBatch>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn receive_batch<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<Vec<RecordBatch>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive zero or more RecordBatches.
An empty Vec means “no data right now” — the caller should poll again.
An error with SourceReason::EOF means the stream has ended.
Sourcefn identifier(&self) -> &str
fn identifier(&self) -> &str
Unique identifier for this source instance (logging / metrics).
Provided Methods§
Sourcefn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize the source. Called once before the first receive_batch().
Default is a no-op.
Sourcefn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Close the source and release all resources.
Must be idempotent — safe to call multiple times or before start().
Default is a no-op.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".