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
impl BandedBuf
Sourcepub fn try_clone(&self) -> Result<BandedBuf, At<BufferError>>
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.
Sourcepub fn new(
width: u32,
height: u32,
format: impl Into<PixelFormat>,
sizing: BandSizing,
) -> Result<BandedBuf, At<BufferError>>
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.
Sourcepub fn new_aligned(
width: u32,
height: u32,
format: impl Into<PixelFormat>,
sizing: BandSizing,
align: RowAlign,
) -> Result<BandedBuf, At<BufferError>>
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.
Sourcepub fn from_buf(
buf: PixelBuf,
sizing: BandSizing,
) -> Result<BandedBuf, At<BufferError>>
pub fn from_buf( buf: PixelBuf, sizing: BandSizing, ) -> Result<BandedBuf, At<BufferError>>
Sourcepub fn from_view(
view: &PixelView<'_>,
sizing: BandSizing,
) -> Result<BandedBuf, At<BufferError>>
pub fn from_view( view: &PixelView<'_>, sizing: BandSizing, ) -> Result<BandedBuf, At<BufferError>>
Sourcepub fn into_buf(self) -> Result<PixelBuf, At<BufferError>>
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.
Sourcepub fn band_count(&self) -> usize
pub fn band_count(&self) -> usize
Number of horizontal bands.
Sourcepub fn band_view(&self, index: usize) -> Option<PixelView<'_>>
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.
Sourcepub fn band_views(&self) -> BandViews<'_> ⓘ
pub fn band_views(&self) -> BandViews<'_> ⓘ
Iterate over every band as a borrowed PixelView with zero allocation and zero
Arc refcount bumps.
Sourcepub fn band_height(&self, index: usize) -> Option<u32>
pub fn band_height(&self, index: usize) -> Option<u32>
Row count of band index, or None if out of bounds.
Sourcepub fn band_stride_bytes(&self, index: usize) -> Option<usize>
pub fn band_stride_bytes(&self, index: usize) -> Option<usize>
Row stride in bytes of band index, or None if out of bounds.
Sourcepub fn band_claims(&self, index: usize) -> Option<SampleClaims>
pub fn band_claims(&self, index: usize) -> Option<SampleClaims>
Attached SampleClaims cached specifically for band index, or None if out of bounds.
Sourcepub const fn locate_row(&self, y: u32) -> Option<BandRowLocation>
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.
Sourcepub fn sub_row_views(
&self,
start_y: u32,
row_count: u32,
) -> Result<Vec<PixelView<'_>>, At<BufferError>>
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).
Sourcepub const fn rows_per_band(&self) -> u32
pub const fn rows_per_band(&self) -> u32
Nominal rows per band (final band may be shorter).
Sourcepub fn band_view_mut(&mut self, index: usize) -> Option<PixelViewMut<'_>>
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.
Sourcepub fn try_cow_band_view_mut(
&mut self,
index: usize,
) -> Result<PixelViewMut<'_>, At<BufferError>>
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).
Sourcepub fn mutate_band_with_claims<F>(
&mut self,
index: usize,
f: F,
) -> Result<(), At<BufferError>>
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.
Sourcepub fn with_bands_mut<R, F>(&mut self, f: F) -> Result<R, At<BufferError>>
pub fn with_bands_mut<R, F>(&mut self, f: F) -> Result<R, At<BufferError>>
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.
Sourcepub fn format(&self) -> &PixelFormat
pub fn format(&self) -> &PixelFormat
Image specification.
Sourcepub const fn attached_claims(&self) -> SampleClaims
pub const fn attached_claims(&self) -> SampleClaims
Cached whole-image sample claims (lattice meet across all bands).
Sourcepub fn assume_claims(&mut self, claims: SampleClaims)
pub fn assume_claims(&mut self, claims: SampleClaims)
Attach caller-asserted SampleClaims uniformly across the whole image and every band.
Sourcepub fn assume_band_claims(
&mut self,
index: usize,
claims: SampleClaims,
) -> Result<(), At<BufferError>>
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.
Sourcepub fn hdr(&self) -> HdrMetadata
pub fn hdr(&self) -> HdrMetadata
Descriptive HDR metadata.
Sourcepub fn hdr_ref(&self) -> Option<&HdrMetadata>
pub fn hdr_ref(&self) -> Option<&HdrMetadata>
Zero-copy reference to attached non-empty HDR metadata (None if empty/unset).
Sourcepub fn with_hdr(self, hdr: HdrMetadata) -> BandedBuf
pub fn with_hdr(self, hdr: HdrMetadata) -> BandedBuf
Attach descriptive HDR metadata in O(1) (single shared metadata slot; zero per-band clones).
Sourcepub fn origin(&self) -> &ColorOrigin
pub fn origin(&self) -> &ColorOrigin
Original container color provenance.
Sourcepub fn with_origin(self, origin: ColorOrigin) -> BandedBuf
pub fn with_origin(self, origin: ColorOrigin) -> BandedBuf
Attach container color provenance in O(1) (single shared metadata slot; zero per-band clones).
Sourcepub const fn orientation(&self) -> Orientation
pub const fn orientation(&self) -> Orientation
Pending EXIF display orientation attached to this banded buffer.
Sourcepub const fn display_dimensions(&self) -> (u32, u32)
pub const fn display_dimensions(&self) -> (u32, u32)
Display-oriented (width, height) after applying orientation.
Sourcepub const fn with_orientation(self, orientation: Orientation) -> BandedBuf
pub const fn with_orientation(self, orientation: Orientation) -> BandedBuf
Replace pending EXIF display orientation in O(1).
Sourcepub fn set_orientation(&mut self, orientation: Orientation)
pub fn set_orientation(&mut self, orientation: Orientation)
Set pending EXIF display orientation in place in O(1).
Sourcepub const fn compose_orientation(self, delta: Orientation) -> BandedBuf
pub const fn compose_orientation(self, delta: Orientation) -> BandedBuf
Compose an additional display transform onto pending orientation in O(1).
Sourcepub fn row_mut(&mut self, y: u32) -> &mut [u8] ⓘ
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.
Trait Implementations§
Source§impl Clone for BandedBuf
impl Clone for BandedBuf
Source§fn clone(&self) -> BandedBuf
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)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl PixelSink for BandedBuf
impl PixelSink for BandedBuf
Source§fn sink_width(&self) -> u32
fn sink_width(&self) -> u32
Source§fn sink_height(&self) -> u32
fn sink_height(&self) -> u32
Source§fn sink_format(&self) -> &PixelFormat
fn sink_format(&self) -> &PixelFormat
Source§fn sink_row_mut(&mut self, y: u32) -> Result<&mut [u8], At<BufferError>>
fn sink_row_mut(&mut self, y: u32) -> Result<&mut [u8], At<BufferError>>
y. Read moreSource§fn sink_finish(&mut self, claims: SampleClaims, hdr: HdrMetadata)
fn sink_finish(&mut self, claims: SampleClaims, hdr: HdrMetadata)
Source§fn sink_set_origin(&mut self, origin: ColorOrigin)
fn sink_set_origin(&mut self, origin: ColorOrigin)
Source§fn sink_set_orientation(&mut self, orientation: Orientation)
fn sink_set_orientation(&mut self, orientation: Orientation)
Source§impl PixelSource for BandedBuf
impl PixelSource for BandedBuf
Source§fn source_width(&self) -> u32
fn source_width(&self) -> u32
Source§fn source_height(&self) -> u32
fn source_height(&self) -> u32
Source§fn source_format(&self) -> &PixelFormat
fn source_format(&self) -> &PixelFormat
Source§fn source_claims(&self) -> SampleClaims
fn source_claims(&self) -> SampleClaims
Source§fn source_hdr(&self) -> HdrMetadata
fn source_hdr(&self) -> HdrMetadata
Source§fn source_origin(&self) -> Option<&ColorOrigin>
fn source_origin(&self) -> Option<&ColorOrigin>
Source§fn source_orientation(&self) -> Orientation
fn source_orientation(&self) -> Orientation
Orientation::Identity).Auto Trait Implementations§
impl !RefUnwindSafe for BandedBuf
impl !UnwindSafe for BandedBuf
impl Freeze for BandedBuf
impl Send for BandedBuf
impl Sync for BandedBuf
impl Unpin for BandedBuf
impl UnsafeUnpin for BandedBuf
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> PixelConvertExt for Swhere
S: PixelSource + ?Sized,
impl<S> PixelConvertExt for Swhere
S: PixelSource + ?Sized,
Source§fn convert_to(
&self,
destination_format: impl AsRef<PixelFormat>,
policy: &ConvertPolicy,
) -> Result<PixelBuf, At<ConvertError>>
fn convert_to( &self, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, ) -> Result<PixelBuf, At<ConvertError>>
Source§fn convert_to_with_peak(
&self,
destination_format: impl AsRef<PixelFormat>,
policy: &ConvertPolicy,
peak: PeakSource,
) -> Result<PixelBuf, At<ConvertError>>
fn convert_to_with_peak( &self, destination_format: impl AsRef<PixelFormat>, policy: &ConvertPolicy, peak: PeakSource, ) -> Result<PixelBuf, At<ConvertError>>
Source§fn convert_into<D: PixelSink + ?Sized>(
&self,
dst: &mut D,
policy: &ConvertPolicy,
) -> Result<(), At<ConvertError>>
fn convert_into<D: PixelSink + ?Sized>( &self, dst: &mut D, policy: &ConvertPolicy, ) -> Result<(), At<ConvertError>>
Source§fn convert_into_with_peak<D: PixelSink + ?Sized>(
&self,
dst: &mut D,
policy: &ConvertPolicy,
peak: PeakSource,
) -> Result<(), At<ConvertError>>
fn convert_into_with_peak<D: PixelSink + ?Sized>( &self, dst: &mut D, policy: &ConvertPolicy, peak: PeakSource, ) -> Result<(), At<ConvertError>>
Source§fn to_rgb8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>>
fn to_rgb8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>>
self to full-range sRGB RGB8, refusing unproven alpha discard
(AlphaPolicy::DiscardIfOpaque). Read moreSource§fn to_gray8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>>
fn to_gray8_if_opaque(&self) -> Result<PixelBuf, At<ConvertError>>
self to full-range sRGB GRAY8, refusing unproven alpha discard
(AlphaPolicy::DiscardIfOpaque). Read more