Skip to main content

Pixel

Trait Pixel 

Source
pub trait Pixel: Pod {
    const DESCRIPTOR: PixelDescriptor;
}
Expand description

Compile-time pixel format descriptor.

Implemented for pixel types to associate them with their PixelDescriptor. This enables typed PixelSlice construction where the type system enforces format correctness.

The trait is open (not sealed) — custom pixel types can implement it. The new_typed() constructors include a compile-time assertion that size_of::<P>() == P::DESCRIPTOR.bytes_per_pixel() to catch bad impls.

Required Associated Constants§

Source

const DESCRIPTOR: PixelDescriptor

The pixel format descriptor for this type.

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§

Source§

impl Pixel for Bgrx

Source§

const DESCRIPTOR: PixelDescriptor = PixelDescriptor::BGRX8

Source§

impl Pixel for Rgbx

Source§

const DESCRIPTOR: PixelDescriptor = PixelDescriptor::RGBX8