Skip to main content

Dataset

Trait Dataset 

pub trait Dataset<I, E = DatasetError>: Send + Sync
where E: Error + Send + Sync + 'static,
{ // Required methods fn get(&self, index: usize) -> Result<I, E>; fn len(&self) -> usize; // Provided methods fn get_many(&self, indexes: Vec<usize>) -> Result<Vec<I>, E> { ... } fn is_empty(&self) -> bool { ... } fn iter(&self) -> DatasetIterator<'_, I, E> ⓘ where Self: Sized { ... } }
Expand description

The dataset trait defines a basic collection of items with a predefined size.

§Panics

get panics if index >= len(), matching slice/Vec indexing conventions. Err(_) is reserved for genuine retrieval failures on an in-bounds index (e.g. an I/O or deserialization failure).

Required Methods§

fn get(&self, index: usize) -> Result<I, E>

Gets the item at the given index.

§Panics

Panics if index >= len().

fn len(&self) -> usize

Gets the number of items in the dataset.

Provided Methods§

fn get_many(&self, indexes: Vec<usize>) -> Result<Vec<I>, E>

Gets the items at given indexes

§Panics

panics if indexes[i] >= len()

fn is_empty(&self) -> bool

Checks if the dataset is empty.

fn iter(&self) -> DatasetIterator<'_, I, E> ⓘ
where Self: Sized,

Returns an iterator over the dataset.

Trait Implementations§

§

impl<I, E> Dataset<I, E> for Box<dyn Dataset<I, E>>
where E: Error + Send + Sync + 'static,

§

fn get(&self, index: usize) -> Result<I, E>

Gets the item at the given index. Read more
§

fn get_many(&self, indexes: Vec<usize>) -> Result<Vec<I>, E>

Gets the items at given indexes Read more
§

fn len(&self) -> usize

Gets the number of items in the dataset.
§

fn is_empty(&self) -> bool

Checks if the dataset is empty.
§

fn iter(&self) -> DatasetIterator<'_, I, E> ⓘ
where Self: Sized,

Returns an iterator over the dataset.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl<D, I, E> Dataset<I, E> for Arc<D>
where D: Dataset<I, E>, E: Error + Send + Sync + 'static,

§

fn get(&self, index: usize) -> Result<I, E>

§

fn get_many(&self, indexes: Vec<usize>) -> Result<Vec<I>, E>

§

fn len(&self) -> usize

§

impl<D, I, E> Dataset<I, E> for Box<D>
where D: Dataset<I, E>, E: Error + Send + Sync + 'static,

§

fn get(&self, index: usize) -> Result<I, E>

§

fn get_many(&self, indexes: Vec<usize>) -> Result<Vec<I>, E>

§

fn len(&self) -> usize

§

impl<I, E> Dataset<I, E> for Arc<dyn Dataset<I, E>>
where E: Error + Send + Sync + 'static,

§

fn get(&self, index: usize) -> Result<I, E>

§

fn get_many(&self, indexes: Vec<usize>) -> Result<Vec<I>, E>

§

fn len(&self) -> usize

§

impl<I, E> Dataset<I, E> for Box<dyn Dataset<I, E>>
where E: Error + Send + Sync + 'static,

§

fn get(&self, index: usize) -> Result<I, E>

§

fn get_many(&self, indexes: Vec<usize>) -> Result<Vec<I>, E>

§

fn len(&self) -> usize

Implementors§

§

impl Dataset<ImageDatasetItem> for ImageFolderDataset

§

impl Dataset<MnistItem> for MnistDataset

§

impl Dataset<SpeechItem, SqliteDatasetError> for SpeechCommandsDataset

§

impl<D, I, E> Dataset<I, E> for ComposedDataset<D>
where D: Dataset<I, E>, I: Clone, E: Error + Send + Sync + 'static,

§

impl<D, I, E> Dataset<I, E> for PartialDataset<D, I>
where D: Dataset<I, E>, I: Clone + Send + Sync, E: Error + Send + Sync + 'static,

§

impl<D, I> Dataset<I> for SamplerDataset<D, I>
where D: Dataset<I>, I: Send + Sync,

§

impl<D, I> Dataset<I> for SelectionDataset<D, I>
where D: Dataset<I>, I: Clone + Send + Sync,

§

impl<D, I> Dataset<I> for ShuffledDataset<D, I>
where D: Dataset<I>, I: Clone + Send + Sync,

§

impl<D, I> Dataset<Vec<I>> for WindowsDataset<D, I>
where D: Dataset<I>, I: Send + Sync,

§

impl<D, M, I, O, E> Dataset<O, E> for MapperDataset<D, M, I>
where D: Dataset<I, E>, M: Mapper<I, O> + Send + Sync, I: Send + Sync, O: Send + Sync, E: Error + Send + Sync + 'static,

§

impl<I> Dataset<I, SqliteDatasetError> for SqliteDataset<I>

§

impl<I> Dataset<I> for InMemDataset<I>
where I: Clone + Send + Sync,