Skip to content

Commit

Permalink
Replace non-exhaustive attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroicKatora committed Apr 5, 2021
1 parent a46aa6d commit c4090eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
25 changes: 18 additions & 7 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::ops::{Index, IndexMut};
use num_traits::{NumCast, ToPrimitive, Zero};

use crate::traits::{Pixel, Primitive};
use crate::utils::NonExhaustiveMarker;

/// An enumeration over supported color types and bit depths
#[derive(Copy, PartialEq, Eq, Debug, Clone, Hash)]
Expand Down Expand Up @@ -31,12 +32,11 @@ pub enum ColorType {
Bgra8,

#[doc(hidden)]
__NonExhaustive(crate::utils::NonExhaustiveMarker),
__NonExhaustive(NonExhaustiveMarker),
}

/// Color information of an image's texels.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Color {
/// The color space is given by an encoded ICC profile.
///
Expand Down Expand Up @@ -65,6 +65,9 @@ pub enum Color {
/// The absolute luminance of the values in the color space.
luminance: Luminance,
},

#[doc(hidden)]
__NonExhaustive(NonExhaustiveMarker),
}

/// Transfer functions from encoded chromatic samples to physical quantity.
Expand All @@ -74,7 +77,6 @@ pub enum Color {
/// describes how scene lighting is encoded as an electric signal. These are applied to each
/// stimulus value.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Transfer {
/// Specified in ITU Rec.709.
Bt709,
Expand All @@ -96,36 +98,45 @@ pub enum Transfer {
Bt2100Pq,
/// ITU Rec.2100 Hybrid Log-Gamma.
Bt2100Hlg,

#[doc(hidden)]
__NonExhaustive(NonExhaustiveMarker),
}

/// The reference brightness of the color specification.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Luminance {
/// 100cd/m².
Sdr,
/// 10_000cd/m².
/// Known as high-dynamic range.
Hdr,

#[doc(hidden)]
__NonExhaustive(NonExhaustiveMarker),
}

/// The relative stimuli of the three corners of a triangular gamut.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Primaries {
Bt601_525,
Bt601_625,
Bt709,
Smpte240,
Bt2020,
Bt2100,

#[doc(hidden)]
__NonExhaustive(NonExhaustiveMarker),
}

/// The whitepoint/standard illuminant.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Whitepoint {
D65,

#[doc(hidden)]
__NonExhaustive(NonExhaustiveMarker),
}

impl ColorType {
Expand Down Expand Up @@ -247,7 +258,7 @@ pub enum ExtendedColorType {
Unknown(u8),

#[doc(hidden)]
__NonExhaustive(crate::utils::NonExhaustiveMarker),
__NonExhaustive(NonExhaustiveMarker),
}

impl ExtendedColorType {
Expand Down
6 changes: 3 additions & 3 deletions src/io/metagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl Recorder {
}

/// Add a color profile.
pub fn color(&self, color: Vec<u8>) {
pub fn color(&self, color: Color) {
self.inner.with_mut(|meta| meta.set_color(color))
}

Expand All @@ -169,7 +169,7 @@ impl SharedRecorder {
}

/// Add a color profile.
pub fn color(&self, color: Vec<u8>) {
pub fn color(&self, color: Color) {
self.with_mut(|meta| meta.set_color(color))
}

Expand All @@ -193,7 +193,7 @@ impl Metagram {
self.height = height;
}

fn set_color(&mut self, color: Vec<u8>) {
fn set_color(&mut self, color: Color) {
self.color_profile = Some(color);
}

Expand Down

0 comments on commit c4090eb

Please sign in to comment.