Skip to main content

SpectralTable

Trait SpectralTable 

Source
pub trait SpectralTable {
    type Value;

    // Required method
    fn table(&self) -> &[(u32, Self::Value)];

    // Provided methods
    fn at(&self, wavelength: u32) -> Option<&Self::Value> { ... }
    fn is_empty(&self) -> bool { ... }
    fn len(&self) -> usize { ... }
    fn max_wavelength(&self) -> Option<u32> { ... }
    fn min_wavelength(&self) -> Option<u32> { ... }
    fn step(&self) -> u32 { ... }
    fn values(&self) -> impl Iterator<Item = &Self::Value> + '_ { ... }
    fn wavelengths(&self) -> impl Iterator<Item = u32> + '_ { ... }
}
Expand description

Common interface for wavelength-indexed spectral data.

All spectral data types (SPD, CMF, chromaticity coordinates, cone fundamentals) implement this trait, providing uniform access to wavelength-value pairs.

Required Associated Types§

Required Methods§

Source

fn table(&self) -> &[(u32, Self::Value)]

Returns the underlying wavelength-value pairs.

Provided Methods§

Source

fn at(&self, wavelength: u32) -> Option<&Self::Value>

Returns the value at the given wavelength, or None if not present.

Source

fn is_empty(&self) -> bool

Returns true if the table contains no entries.

Source

fn len(&self) -> usize

Returns the number of wavelength-value pairs.

Source

fn max_wavelength(&self) -> Option<u32>

Returns the maximum wavelength in the table, or None if empty.

Source

fn min_wavelength(&self) -> Option<u32>

Returns the minimum wavelength in the table, or None if empty.

Source

fn step(&self) -> u32

Returns the minimum step size between consecutive wavelengths.

Source

fn values(&self) -> impl Iterator<Item = &Self::Value> + '_

Returns an iterator over the values (without wavelengths).

Source

fn wavelengths(&self) -> impl Iterator<Item = u32> + '_

Returns an iterator over the wavelengths (without values).

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§