Sampler

Trait Sampler 

Source
pub trait Sampler<T> {
    type BatchData;

    // Required method
    fn sample(&self, data: Vec<T>) -> Vec<Self::BatchData>;

    // Provided methods
    fn sample_slice(&self, data: &[T]) -> Vec<Self::BatchData>
       where T: Clone { ... }
    fn sample_iter<I>(&self, data: I) -> Vec<Self::BatchData>
       where I: IntoIterator<Item = T> { ... }
}
Expand description

Trait for sampling data into batches.

This trait defines the interface for sampling data into batches for processing.

Required Associated Types§

Source

type BatchData

The type of batch data produced by this sampler.

Required Methods§

Source

fn sample(&self, data: Vec<T>) -> Vec<Self::BatchData>

Samples the given data into batches.

§Arguments
  • data - The data to sample.
§Returns

A vector of batch data.

Provided Methods§

Source

fn sample_slice(&self, data: &[T]) -> Vec<Self::BatchData>
where T: Clone,

Samples the given slice of data into batches.

§Arguments
  • data - The slice of data to sample.
§Returns

A vector of batch data.

§Constraints
  • T must implement Clone.
Source

fn sample_iter<I>(&self, data: I) -> Vec<Self::BatchData>
where I: IntoIterator<Item = T>,

Samples the given iterator of data into batches.

§Arguments
  • data - The iterator of data to sample.
§Returns

A vector of batch data.

§Constraints
  • I must implement IntoIterator<Item = T>.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§