pub trait DataSource: Send + Sync {
type Sample: Storage + ?Sized;
type Error: Error + Display + Send + Sync + 'static;
// Required methods
fn next_batch(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
completion: CompletionHandle<(Box<Self::Sample>, Box<Self::Sample>), Self::Error>,
) -> ContractResponse<(Box<Self::Sample>, Box<Self::Sample>), Self::Error>;
fn reset(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
completion: CompletionHandle<(), Self::Error>,
) -> ContractResponse<(), Self::Error>;
fn on_data_loaded(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
completion: CompletionHandle<(), Self::Error>,
) -> ContractResponse<(), Self::Error>;
}Expand description
User-facing Contract trait for a data source / data loader.
Required Associated Types§
Required Methods§
Sourcefn next_batch(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
completion: CompletionHandle<(Box<Self::Sample>, Box<Self::Sample>), Self::Error>,
) -> ContractResponse<(Box<Self::Sample>, Box<Self::Sample>), Self::Error>
fn next_batch( &mut self, ctx: &mut RuntimeResourceRef<'_>, completion: CompletionHandle<(Box<Self::Sample>, Box<Self::Sample>), Self::Error>, ) -> ContractResponse<(Box<Self::Sample>, Box<Self::Sample>), Self::Error>
Fetch the next batch. Returns (batch, labels) as boxed
Self::Sample slices; the second slot is zero-length for
unsupervised sources.
Sourcefn reset(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
completion: CompletionHandle<(), Self::Error>,
) -> ContractResponse<(), Self::Error>
fn reset( &mut self, ctx: &mut RuntimeResourceRef<'_>, completion: CompletionHandle<(), Self::Error>, ) -> ContractResponse<(), Self::Error>
Reset to the beginning of the data stream.
Sourcefn on_data_loaded(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
completion: CompletionHandle<(), Self::Error>,
) -> ContractResponse<(), Self::Error>
fn on_data_loaded( &mut self, ctx: &mut RuntimeResourceRef<'_>, completion: CompletionHandle<(), Self::Error>, ) -> ContractResponse<(), Self::Error>
One-shot notification signalling the source’s data has finished loading (e.g. dataset download complete).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".