#[non_exhaustive]pub struct LoadBearingReport {
pub uses_alpha: Option<bool>,
pub uses_chroma: Option<bool>,
pub uses_low_bits: Option<bool>,
}Expand description
What a buffer’s content actually exercises about its declared
descriptor. Each field is Option<T> so it self-reports whether
the predicate was actually measured against this buffer:
Some(value)– the predicate ran;valuereflects measured truthNone– the predicate didn’t run (channel type unsupported, or the field doesn’t apply to this layout). Codecs should treatNoneas “I don’t know – keep the conservative interpretation”.
For boolean fields, the interesting signal for codecs is Some(false):
“this dimension isn’t load-bearing, it’s safe to narrow”. Some(true)
or None both mean “leave it alone”.
Default::default() produces an all-None report – the safe starting
state when no analysis has run.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.uses_alpha: Option<bool>Some(true) → at least one alpha sample is not channel-max
(alpha is load-bearing). Some(false) → alpha can be dropped
(every sample is channel-max, OR the layout has no alpha
channel – codec drops alpha either way). None → predicate
didn’t run (unsupported channel type).
uses_chroma: Option<bool>Some(true) → at least one pixel has differing chroma channels
(R != G or G != B). Some(false) → no chroma variation (either
R==G==B everywhere or the layout is already grayscale). None
→ predicate didn’t run.
uses_low_bits: Option<bool>Some(true) → at least one U16 sample has its low byte differ
from its high byte. Some(false) → no information lost in
U16 → U8 narrowing (either bit-replicated samples or the
buffer is already at U8). None → predicate didn’t run (F32,
F16, etc.).
Implementations§
Source§impl LoadBearingReport
impl LoadBearingReport
Sourcepub const fn any_analyzed(&self) -> bool
pub const fn any_analyzed(&self) -> bool
True if the analysis returned at least one non-None field –
i.e. some predicate ran (or answered structurally). Codecs that
need a quick “is there anything actionable here” check before
consulting individual fields; false means the buffer’s
layout × channel-type combination isn’t wired and the report
carries no information.
Sourcepub fn apply_to(&self, src: &PixelDescriptor) -> PixelDescriptor
pub fn apply_to(&self, src: &PixelDescriptor) -> PixelDescriptor
Produce the narrowest descriptor justified by this report.
Order of reduction (each step’s outcome feeds the next):
- Channel-type narrowing (U16 → U8 when
uses_low_bitsis false) - Alpha drop (when
uses_alphais false and the layout has alpha) - Chroma drop (when
uses_chromais false and the layout has chroma)
Color signaling (primaries, transfer, signal range) carries over
from src untouched – a load-bearing reduction never re-tags
color, because every reduction here keeps stored values exact.
Alpha drop from Bgra narrows to Rgb – there is no Bgr
layout, so the buffer rewrite in
PixelSliceLoadBearingExt::try_reduce_to_load_bearing_format
reorders channels (B,G,R,A → R,G,B). Callers applying this
descriptor with their own rewrite must do the same reorder.
If a step would yield an unrepresentable (channel_type, layout, alpha) triple, the source format is kept.
Trait Implementations§
Source§impl Clone for LoadBearingReport
impl Clone for LoadBearingReport
Source§fn clone(&self) -> LoadBearingReport
fn clone(&self) -> LoadBearingReport
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more