palette/
encoding.rs

1//! Number and color encoding traits, types and standards.
2//!
3//! Some color spaces, particularly RGB, may be encoded in more than one way and
4//! may have more than one standard. These encodings and standards are
5//! represented as type parameters in Palette, as a form of type branding, to
6//! prevent accidental mixups.
7
8pub use self::gamma::{F2p2, Gamma};
9pub use self::linear::Linear;
10pub use self::srgb::Srgb;
11
12pub mod gamma;
13pub mod linear;
14pub mod srgb;
15
16/// A transfer function from linear space.
17pub trait FromLinear<L, E> {
18    /// Convert the color component `linear` from linear space.
19    #[must_use]
20    fn from_linear(linear: L) -> E;
21}
22
23/// A transfer function to linear space.
24pub trait IntoLinear<L, E> {
25    /// Convert the color component `encoded` into linear space.
26    #[must_use]
27    fn into_linear(encoded: E) -> L;
28}