Skip to main content

SampleClaims

Struct SampleClaims 

Source
#[non_exhaustive]
pub struct SampleClaims { pub float: FloatClaims, pub depth: Option<ExactDepth>, pub all_opaque: bool, pub all_grayscale: bool, pub binary_alpha: bool, }
Expand description

Positive claims about active sample values, stored as inline image metadata.

Each true flag or populated field asserts its property. Self::NONE carries no claims. Fill constructors seed these fields from known samples, and callers can attach measured or caller-asserted values for conversion plans to rely on.

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.
§float: FloatClaims

Claimed floating-point invariants.

§depth: Option<ExactDepth>

Claimed exact integer code-grid depth (range-aware, separate color & alpha grids).

§all_opaque: bool

Claimed that every active alpha sample equals channel max (or layout has no meaningful alpha).

§all_grayscale: bool

Claimed that R == G == B for every pixel (or layout is already grayscale).

§binary_alpha: bool

Claimed that every active alpha sample is either 0 or channel max (binary transparency).

Implementations§

Source§

impl SampleClaims

Source

pub const NONE: SampleClaims

Unknown / unclaimed sample properties.

Source

pub const fn with_float(self, float: FloatClaims) -> SampleClaims

Set floating-point claims.

Source

pub fn with_depth(self, depth: impl Into<Option<ExactDepth>>) -> SampleClaims

Attach (or clear with None) an ExactDepth claim.

Accepts either ExactDepth directly or Option<ExactDepth>.

Source

pub const fn for_black_format(format: &PixelFormat) -> SampleClaims

Claims guaranteed for a freshly allocated black-filled buffer of format (as produced by PixelBuf::new: color channels zeroed and AlphaMode::Opaque alpha slots initialized to channel maximum).

Source

pub const fn for_signal_white_format(format: &PixelFormat) -> SampleClaims

Claims guaranteed for a freshly allocated signal-white-filled buffer of format (color channels filled with the format’s nominal signal-white sample pattern and alpha filled to channel maximum).

Source

pub const fn from_float(float: FloatClaims) -> SampleClaims

Construct claims carrying only FloatClaims.

Source

pub const fn from_depth(depth: ExactDepth) -> SampleClaims

Construct claims carrying ExactDepth.

Source

pub const fn with_all_opaque(self, all_opaque: bool) -> SampleClaims

Attach all_opaque claim (also implies binary_alpha when true).

Source

pub const fn with_all_grayscale(self, all_grayscale: bool) -> SampleClaims

Attach all_grayscale claim.

Source

pub const fn with_binary_alpha(self, binary_alpha: bool) -> SampleClaims

Attach binary_alpha claim.

Source

pub const fn is_exact_at(self, color_bits: u8, alpha_bits: u8) -> bool

Whether current full-range/narrow integer samples are claimed exact at color_bits and alpha_bits.

Source

pub const fn is_color_exact_at(self, color_bits: u8) -> bool

Whether current integer color channels are claimed exact at color_bits (ignoring alpha depth).

Source

pub const fn union_disjoint_regions( a: SampleClaims, b: SampleClaims, ) -> SampleClaims

Combine claims from two disjoint regions or bands of the same image into claims guaranteed across their union.

Every property holds on the combined image iff it holds across both regions:

  • float: bitwise intersection (a.float.intersect(b.float))
  • depth: ExactDepth::union_disjoint_regions (None if either is unclaimed or incompatible)
  • all_opaque, all_grayscale, binary_alpha: logical AND (&&)
Source

pub const fn intersect_same_buffer( a: SampleClaims, b: SampleClaims, ) -> SampleClaims

Combine two independent claim sets that both describe the same buffer into the tighter claim set.

  • float: bitwise union (a.float.union(b.float))
  • depth: ExactDepth::intersect_same_buffer when both are present (or whichever is present)
  • all_opaque, all_grayscale, binary_alpha: logical OR (||)

Trait Implementations§

Source§

impl Clone for SampleClaims

Source§

fn clone(&self) -> SampleClaims

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 SampleClaims

Source§

impl Debug for SampleClaims

Source§

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

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

impl Default for SampleClaims

Source§

fn default() -> SampleClaims

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

impl Eq for SampleClaims

Source§

impl Hash for SampleClaims

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SampleClaims

Source§

fn eq(&self, other: &SampleClaims) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SampleClaims

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.