Skip to main content

BandedBuf

Struct BandedBuf 

Source
pub struct BandedBuf { /* private fields */ }
Expand description

Gigapixel-safe image stored as compact bounded-size horizontal bands.

Shares a single authoritative PixelFormat, HdrMetadata, ColorOrigin, and Orientation across all bands (zero per-band Arc clones or duplicated format headers) while tracking independent per-band SampleClaims for localized mutation and parallel band processing. Implements both PixelSource and PixelSink.

Implementations§

Source§

impl BandedBuf

Source

pub fn try_clone(&self) -> Result<BandedBuf, At<BufferError>>

Fallibly clone this banded buffer, preserving sample alignment, per-band SampleClaims, metadata, origin, and orientation even under odd-byte allocators.

Source

pub fn new( width: u32, height: u32, format: impl Into<PixelFormat>, sizing: BandSizing, ) -> Result<BandedBuf, At<BufferError>>

Fallibly allocate a black-filled banded image partitioned according to sizing (BandSizing::MaxBandBytes or BandSizing::RowsPerBand).

Note: all bands are allocated upfront, so MaxBandBytes bounds each individual contiguous allocation rather than total image residency.

Source

pub fn new_aligned( width: u32, height: u32, format: impl Into<PixelFormat>, sizing: BandSizing, align: RowAlign, ) -> Result<BandedBuf, At<BufferError>>

Fallibly allocate a black-filled banded image with explicit per-band RowAlign.

Source

pub fn from_buf( buf: PixelBuf, sizing: BandSizing, ) -> Result<BandedBuf, At<BufferError>>

Split a contiguous PixelBuf into a BandedBuf partitioned according to sizing. Moves buf zero-copy into a single band when the entire image fits within one band.

Source

pub fn from_view( view: &PixelView<'_>, sizing: BandSizing, ) -> Result<BandedBuf, At<BufferError>>

Copy a borrowed PixelView into a newly allocated BandedBuf, preserving claims, hdr, origin, and orientation.

Source

pub fn into_buf(self) -> Result<PixelBuf, At<BufferError>>

Materialize this banded image into a single contiguous PixelBuf.

Moves the single band zero-copy when self.band_count() == 1; otherwise fallibly gathers active rows into native-aligned storage while preserving claims, hdr, origin, and orientation.

Source

pub fn band_count(&self) -> usize

Number of horizontal bands.

Source

pub fn band_view(&self, index: usize) -> Option<PixelView<'_>>

Borrow band index immutably as a PixelView (zero Arc refcount bump), carrying that band’s individual SampleClaims.

Source

pub fn band_views(&self) -> BandViews<'_> ⓘ

Iterate over every band as a borrowed PixelView with zero allocation and zero Arc refcount bumps.

Source

pub fn band_height(&self, index: usize) -> Option<u32>

Row count of band index, or None if out of bounds.

Source

pub fn band_stride_bytes(&self, index: usize) -> Option<usize>

Row stride in bytes of band index, or None if out of bounds.

Source

pub fn band_claims(&self, index: usize) -> Option<SampleClaims>

Attached SampleClaims cached specifically for band index, or None if out of bounds.

Source

pub const fn locate_row(&self, y: u32) -> Option<BandRowLocation>

Map global row y to its band index and band-local row offset, or None if out of bounds.

Source

pub fn sub_row_views( &self, start_y: u32, row_count: u32, ) -> Result<Vec<PixelView<'_>>, At<BufferError>>

Borrow zero-copy PixelView slices covering global row range start_y..start_y + row_count, split at band boundaries (zero Arc refcount bump).

Source

pub const fn width(&self) -> u32

Frame width in pixels.

Source

pub const fn height(&self) -> u32

Frame height in rows.

Source

pub const fn rows_per_band(&self) -> u32

Nominal rows per band (final band may be shorter).

Source

pub fn band_view_mut(&mut self, index: usize) -> Option<PixelViewMut<'_>>

Borrow band index mutably as a PixelViewMut without allowing structural band replacement, clearing cached SampleClaims on band index and the outer BandedBuf while leaving all other bands’ attached claims intact (zero Arc refcount bump).

Copy-on-write promotes immutable external storage if needed; use try_cow_band_view_mut for fallible OOM handling.

Source

pub fn try_cow_band_view_mut( &mut self, index: usize, ) -> Result<PixelViewMut<'_>, At<BufferError>>

Fallibly borrow band index mutably as a PixelViewMut, copy-on-write promoting immutable external storage without panicking on OOM and clearing cached SampleClaims only on band index and the whole-image summary (other bands remain intact).

Source

pub fn mutate_band_with_claims<F>( &mut self, index: usize, f: F, ) -> Result<(), At<BufferError>>

Mutate band index in place with access to that band’s starting SampleClaims, atomically committing its updated SampleClaims and recomputing whole-image attached_claims via SampleClaims::union_disjoint_regions.

Localized & panic/error safe: Clears only band index’s claims (and the whole-image summary) before invoking f; all untouched bands preserve their attached SampleClaims. If f panics or returns Err(_), band index stays at SampleClaims::NONE.

Source

pub fn with_bands_mut<R, F>(&mut self, f: F) -> Result<R, At<BufferError>>
where F: FnOnce(&mut [BandMut<'_>]) -> R,

Borrow all bands simultaneously as disjoint Send BandMut handles for sequential or parallel (e.g. rayon) in-place mutation with contention-free per-band SampleClaims.

Fallibly copy-on-write promotes any immutable external bands upfront before clearing claims. Each BandMut exposes its band’s starting_claims and lets the worker commit updated claims via BandMut::commit_claims or BandMut::keep_starting_claims. When f returns, whole-image attached_claims is recomputed across all bands via SampleClaims::union_disjoint_regions.

Source

pub fn format(&self) -> &PixelFormat

Image specification.

Source

pub const fn attached_claims(&self) -> SampleClaims

Cached whole-image sample claims (lattice meet across all bands).

Source

pub fn assume_claims(&mut self, claims: SampleClaims)

Attach caller-asserted SampleClaims uniformly across the whole image and every band.

Source

pub fn assume_band_claims( &mut self, index: usize, claims: SampleClaims, ) -> Result<(), At<BufferError>>

Attach caller-asserted SampleClaims for band index and recompute whole-image attached_claims via SampleClaims::union_disjoint_regions.

Source

pub fn hdr(&self) -> HdrMetadata

Descriptive HDR metadata.

Source

pub fn hdr_ref(&self) -> Option<&HdrMetadata>

Zero-copy reference to attached non-empty HDR metadata (None if empty/unset).

Source

pub fn with_hdr(self, hdr: HdrMetadata) -> BandedBuf

Attach descriptive HDR metadata in O(1) (single shared metadata slot; zero per-band clones).

Source

pub fn origin(&self) -> &ColorOrigin

Original container color provenance.

Source

pub fn with_origin(self, origin: ColorOrigin) -> BandedBuf

Attach container color provenance in O(1) (single shared metadata slot; zero per-band clones).

Source

pub const fn orientation(&self) -> Orientation

Pending EXIF display orientation attached to this banded buffer.

Source

pub const fn display_dimensions(&self) -> (u32, u32)

Display-oriented (width, height) after applying orientation.

Source

pub const fn with_orientation(self, orientation: Orientation) -> BandedBuf

Replace pending EXIF display orientation in O(1).

Source

pub fn set_orientation(&mut self, orientation: Orientation)

Set pending EXIF display orientation in place in O(1).

Source

pub const fn compose_orientation(self, delta: Orientation) -> BandedBuf

Compose an additional display transform onto pending orientation in O(1).

Source

pub fn row(&self, y: u32) -> &[u8] ⓘ

Active bytes of global row y.

Source

pub fn row_mut(&mut self, y: u32) -> &mut [u8] ⓘ

Mutable active bytes of global row y, clearing cached SampleClaims only on the containing band and outer summary (untouched bands retain their attached claims).

§Panics

Panics if y >= self.height(), or if copy-on-write promotion of immutable external storage fails to allocate.

Source§

impl BandedBuf

Source

pub fn hash_with(&self, inclusions: HashInclusions) -> u64

Compute a portable, endian-, stride-, and band-size-independent XXH3 fingerprint.

Guaranteed to equal PixelBuf::hash_with for the same pixels and metadata.

Trait Implementations§

Source§

impl Clone for BandedBuf

Source§

fn clone(&self) -> BandedBuf

Clone this banded buffer, preserving alignment, per-band claims, metadata, origin, and orientation even under odd-byte allocators.

§Panics

Panics on allocation failure; use BandedBuf::try_clone for fallible cloning.

1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BandedBuf

Source§

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

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

impl PixelSink for BandedBuf

Source§

fn sink_width(&self) -> u32

Frame width in pixels.
Source§

fn sink_height(&self) -> u32

Frame height in rows.
Source§

fn sink_format(&self) -> &PixelFormat

Authoritative destination specification.
Source§

fn sink_row_mut(&mut self, y: u32) -> Result<&mut [u8], At<BufferError>>

Fallibly borrow mutable active bytes of row y. Read more
Source§

fn sink_finish(&mut self, claims: SampleClaims, hdr: HdrMetadata)

Propagate output claims & HDR metadata on owned sinks (no-op on borrowed views).
Source§

fn sink_set_origin(&mut self, origin: ColorOrigin)

Propagate original container color provenance onto owned sinks (no-op on borrowed views).
Source§

fn sink_set_orientation(&mut self, orientation: Orientation)

Propagate pending EXIF display orientation onto sinks.
Source§

impl PixelSource for BandedBuf

Source§

fn source_width(&self) -> u32

Frame width in pixels.
Source§

fn source_height(&self) -> u32

Frame height in rows.
Source§

fn source_format(&self) -> &PixelFormat

Authoritative image specification.
Source§

fn source_claims(&self) -> SampleClaims

Attached sample claims.
Source§

fn source_hdr(&self) -> HdrMetadata

Descriptive HDR metadata.
Source§

fn source_origin(&self) -> Option<&ColorOrigin>

Original container color provenance, if attached.
Source§

fn source_orientation(&self) -> Orientation

Pending EXIF display orientation (defaults to Orientation::Identity).
Source§

fn source_row(&self, y: u32) -> &[u8] ⓘ

Active bytes of row y.

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<S> PixelConvertExt for S
where S: PixelSource + ?Sized,

Source§

fn convert_to( &self, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, ) -> Result<PixelBuf, At<ConvertError>>

Convert self into a newly allocated tightly packed PixelBuf. Read more
Source§

fn convert_to_with_peak( &self, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, peak: PeakSource, ) -> Result<PixelBuf, At<ConvertError>>

Convert self into a newly allocated PixelBuf with an explicit PeakSource.
Source§

fn convert_into<D: PixelSink + ?Sized>( &self, dst: &mut D, policy: &ConvertPolicy, ) -> Result<(), At<ConvertError>>

Convert self directly into any existing PixelSink (PixelBuf, PixelViewMut, or BandedBuf).
Source§

fn convert_into_with_peak<D: PixelSink + ?Sized>( &self, dst: &mut D, policy: &ConvertPolicy, peak: PeakSource, ) -> Result<(), At<ConvertError>>

Convert self directly into any existing PixelSink with an explicit PeakSource.
Source§

fn to_rgb8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>>

Convert self to full-range sRGB RGB8, refusing unproven alpha discard (AlphaPolicy::DiscardIfOpaque). Read more
Source§

fn to_rgba8(&self) -> Result<PixelBuf, At<ConvertError>>

Convert self to full-range sRGB straight-alpha RGBA8 under ConvertPolicy::permissive.
Source§

fn to_gray8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>>

Convert self to full-range sRGB GRAY8, refusing unproven alpha discard (AlphaPolicy::DiscardIfOpaque). Read more
Source§

fn to_bgra8(&self) -> Result<PixelBuf, At<ConvertError>>

Convert self to full-range sRGB straight-alpha BGRA8 under ConvertPolicy::permissive.
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.