Skip to main content

LoadBearingReport

Struct LoadBearingReport 

Source
#[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; value reflects measured truth
  • None – the predicate didn’t run (channel type unsupported, or the field doesn’t apply to this layout). Codecs should treat None as “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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

Source

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.

Source

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):

  1. Channel-type narrowing (U16 → U8 when uses_low_bits is false)
  2. Alpha drop (when uses_alpha is false and the layout has alpha)
  3. Chroma drop (when uses_chroma is 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

Source§

fn clone(&self) -> LoadBearingReport

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LoadBearingReport

Source§

impl Debug for LoadBearingReport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LoadBearingReport

Source§

fn default() -> LoadBearingReport

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.