Skip to main content

Pixel

Trait Pixel 

Source
pub trait Pixel:
    Copy
    + Pod
    + Zeroable
    + Send
    + Sync
    + 'static {
    const MODE: PixelMode;
    const BYTES: usize;
}
Expand description

Re-export every public type from the color crate, including all arithmetic helpers from color::convert.

Downstream modules within this crate can import everything they need with a single use crate::types::*. A typed pixel value that can be stored in a Bitmap<P> row buffer.

All implementations are Copy + Pod, enabling zero-copy row access via bytemuck::cast_slice. BYTES must match std::mem::size_of::<Self>(); compile-time assertions in this module enforce the invariant.

Required Associated Constants§

Source

const MODE: PixelMode

The PixelMode variant that identifies this pixel format at runtime.

Source

const BYTES: usize

Byte width of one pixel. Must equal std::mem::size_of::<Self>().

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 Cmyk8

Source§

const MODE: PixelMode = PixelMode::Cmyk8

Source§

const BYTES: usize = 4

Source§

impl Pixel for DeviceN8

Source§

const MODE: PixelMode = PixelMode::DeviceN8

Source§

const BYTES: usize = 8

Source§

impl Pixel for Gray8

Source§

const MODE: PixelMode = PixelMode::Mono8

Source§

const BYTES: usize = 1

Source§

impl Pixel for Rgb8

Source§

const MODE: PixelMode = PixelMode::Rgb8

Source§

const BYTES: usize = 3

Source§

impl Pixel for Rgba8

Source§

const MODE: PixelMode = PixelMode::Xbgr8

Source§

const BYTES: usize = 4