Skip to main content

Module format

Module format 

Source
Expand description

HAL pixel format, as reported in TensorDesc::format.

Same ABI concern as [dtype]: these codes cross a package boundary, so they are appended, never reordered. crate::PixelFormat itself generates this module’s per-variant constants (via ef_vocabulary!, see vocabulary.rs), so this and crate::PixelFormat::code are two views of the same declared literal per variant, not two hand-kept tables that could drift apart. format::NONE is the one constant this module adds beyond what the macro emits – see its own doc.

This exists because TensorDesc::fourcc cannot represent every HAL format: PlanarRgb/PlanarRgba have no standard FourCC and both encode as fourcc = 0, the same sentinel a non-image tensor uses, so fourcc alone cannot tell “Planar RGB” apart from “no format”. fourcc stays for third-party interop; a HAL-aware consumer prefers format and falls back to fourcc only when format is 0.

protocol::format is the canonical, documented path – the source module, crate::pixel_format_wire, is #[doc(hidden)] because it exists only so this re-export has something public to alias; it is emission plumbing, not a second API for the same codes.

Constants§

BGRA
GREY
NONE
No format (non-image tensor), or a format this build predates. Not a crate::PixelFormat variant – every code 1..=11 below is one of those, generated by the same ef_vocabulary! declaration as crate::PixelFormat::code; 0 is a sentinel this module alone defines, since “no format” has no corresponding Rust variant.
NV12
NV16
NV24
PLANAR_RGB
PLANAR_RGBA
RGB
RGBA
VYUY
YUYV