fovea-derive 0.1.1

Derive macros for fovea pixel and image traits
Documentation

fovea-derive

Crates.io Documentation License: MIT

fovea-derive provides the procedural macros used by fovea to derive pixel layout and arithmetic traits.

Most users should depend on fovea and use the derive macros re-exported from that crate. Depend on fovea-derive directly only if you are working on the fovea internals or need the macro crate explicitly.

[dependencies]

fovea = "0.1.1"

Derives

Derive Purpose
PlainPixel Declares that a pixel has a stable byte layout suitable for byte-level access.
HomogeneousPixel Declares that all channels have the same channel type.
ZeroablePixel Generates a zero value for image allocation and initialization.
LinearPixel Generates linear-space arithmetic support with an explicit accumulator type.

Example

use fovea::{HomogeneousPixel, PlainPixel, ZeroablePixel};
use std::num::Saturating;

#[derive(Clone, Copy, PlainPixel, HomogeneousPixel, ZeroablePixel)]
#[repr(C)]
pub struct Rgb8 {
    pub r: Saturating<u8>,
    pub g: Saturating<u8>,
    pub b: Saturating<u8>,
}

The derives intentionally enforce fovea's pixel model: memory layout is explicit, channel roles are named, and invalid trait implementations should fail during compilation rather than at runtime.

Part of the fovea project

License

Licensed under the MIT License.