Skip to main content

PlaneBuf

Struct PlaneBuf 

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

Full re-export of zenpixels core types (zero module name collisions!). Owned single plane inside a PlanarBuf with validated geometry invariants.

Implementations§

Source§

impl PlaneBuf

Source

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

Fallibly clone this plane, preserving sample alignment even under odd-byte allocators.

Source

pub fn from_storage( storage: PixelStorage, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, At<BufferError>>

Construct a validated owned plane adopting caller-provided PixelStorage zero-copy.

Source

pub fn from_storage_with_byte_offset( storage: PixelStorage, byte_offset: usize, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, At<BufferError>>

Construct a validated owned plane adopting caller-provided PixelStorage starting at byte_offset bytes zero-copy.

Source

pub fn from_external<S>( storage: S, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, (At<BufferError>, S)>
where S: ByteStorage + Send + Sync + 'static,

Construct a validated owned plane adopting an immutable external owner (Arc<[u8]>, Arc<[u16]>, mmap, etc.) zero-copy. Returns Err((err, storage)) untouched on failure.

Source

pub fn from_external_with_byte_offset<S>( storage: S, byte_offset: usize, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, (At<BufferError>, S)>
where S: ByteStorage + Send + Sync + 'static,

Construct a validated owned plane adopting an immutable external owner starting at byte_offset bytes zero-copy. Returns Err((err, storage)) untouched on failure.

Source

pub fn from_external_mut<S>( storage: S, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, (At<BufferError>, S)>
where S: ByteStorageMut + Send + Sync + 'static,

Construct a validated owned plane adopting a mutable external owner (Box<[T]>, custom allocator, pool lease, etc.) zero-copy. Returns Err((err, storage)) untouched on failure.

Source

pub fn from_external_mut_with_byte_offset<S>( storage: S, byte_offset: usize, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, (At<BufferError>, S)>
where S: ByteStorageMut + Send + Sync + 'static,

Construct a validated owned plane adopting a mutable external owner starting at byte_offset bytes zero-copy. Returns Err((err, storage)) untouched on failure.

Source

pub const fn byte_offset(&self) -> usize

Byte offset of row 0 inside backing storage.

Source

pub fn into_storage(self) -> PixelStorage

Consume this plane and return its backing PixelStorage.

Source

pub fn into_external<S>(self) -> Result<S, PlaneBuf>
where S: 'static,

Recover an immutable external owner S zero-copy; returns Err(self) untouched otherwise.

Source

pub fn into_external_mut<S>(self) -> Result<S, PlaneBuf>
where S: 'static,

Recover a mutable external owner S zero-copy; returns Err(self) untouched otherwise.

Source

pub fn make_mut(&mut self) -> Result<(), At<BufferError>>

Ensure backing storage is mutable in place, fallibly promoting immutable external storage (PixelStorage::External) via copy-on-write into properly aligned owned storage covering only the active plane extent (never copying an entire external slab).

No-op (zero copy, zero allocation) for native Vec, Aligned64, and ExternalMut planes.

Source

pub fn try_cow_view_mut(&mut self) -> Result<PlaneViewMut<'_>, At<BufferError>>

Fallibly borrow as a mutable PlaneViewMut, performing active-extent copy-on-write promotion of immutable external storage without panicking on OOM.

Source

pub const fn format(&self) -> PlaneFormat

Plane specification.

Source

pub const fn width(&self) -> u32

Plane width in elements.

Source

pub const fn height(&self) -> u32

Plane height in rows.

Source

pub const fn stride_bytes(&self) -> usize

Row stride in bytes.

Source

pub const fn row_bytes(&self) -> usize

Active bytes per row.

Source

pub fn storage(&self) -> &PixelStorage

Backing storage reference.

Source

pub fn as_view(&self) -> PlaneView<'_>

Borrow as an immutable PlaneView.

Source

pub fn as_view_mut(&mut self) -> PlaneViewMut<'_>

Borrow as a mutable PlaneViewMut, copy-on-write promoting immutable external storage covering only the active plane extent.

Source

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

Immutable active bytes of plane row y.

Source

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

Mutable active bytes of plane row y.

Source

pub fn from_samples<S>( samples: Vec<S>, width: u32, height: u32, format: PlaneFormat, ) -> Result<PlaneBuf, At<BufferError>>
where S: StorageSample,

Construct a validated owned plane adopting a tightly packed typed Vec<S> (Vec<u8>, Vec<u16>, Vec<f32>, etc.) zero-copy.

Row stride is derived automatically as width * format.components() samples (e.g. width for luma Y, width * 2 for semi-planar CbCr). For padded row strides, use from_samples_strided.

Source

pub fn from_samples_strided<S>( samples: Vec<S>, width: u32, height: u32, stride: SampleStride, format: PlaneFormat, ) -> Result<PlaneBuf, At<BufferError>>
where S: StorageSample,

Construct a validated owned plane adopting a strided typed Vec<S> (Vec<u8>, Vec<u16>, Vec<f32>, etc.) zero-copy with an explicit SampleStride measured in S elements (NOT bytes).

Source

pub fn crop_view( &self, rect: PixelRect, ) -> Result<PlaneView<'_>, At<BufferError>>

Borrow a zero-copy rectangular crop of this single plane.

Source

pub fn crop_view_mut( &mut self, rect: PixelRect, ) -> Result<PlaneViewMut<'_>, At<BufferError>>

Borrow a zero-copy mutable rectangular crop of this single plane, fallibly copy-on-write promoting immutable external storage if needed.

Source

pub fn row_as<S>(&self, y: u32) -> Result<&[S], At<BufferError>>
where S: StorageSample,

Zero-copy typed slice view of row y (e.g. plane.row_as::<u16>(y)).

Source

pub fn row_as_mut<S>(&mut self, y: u32) -> Result<&mut [S], At<BufferError>>
where S: StorageSample,

Zero-copy mutable typed slice view of row y (e.g. plane.row_as_mut::<u16>(y)).

Source

pub fn code_u32(&self, x: u32, y: u32, component: usize) -> Option<u32>

Extract the unpacked integer code for (x, y, component) respecting BitPacking.

component is the 0-based channel index within this plane: pass 0 for single-channel planes (Y, Cb, Cr, R, G, B, Alpha), or 0/1 for interleaved CbCr.

Source§

impl PlaneBuf

Source

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

Compute a portable, endian- and stride-independent XXH3 fingerprint of this owned plane.

Trait Implementations§

Source§

impl Clone for PlaneBuf

Source§

fn clone(&self) -> PlaneBuf

Clone this plane, preserving sample alignment even under odd-byte allocators.

§Panics

Panics on allocation failure when repacking misaligned backing storage; use PlaneBuf::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 PlaneBuf

Source§

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

Formats the value using the given formatter. 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.