pub struct PlaneBytes<const N: usize> { /* private fields */ }Expand description
An array of byte matrices.
This type is optimized for the concrete layout type.
use image_texel::texels::{U8, F32};
use image_texel::layout::{Layout, PlaneBytes, MatrixBytes};
let m0 = MatrixBytes::from_width_height(U8.into(), 4, 4).unwrap();
let m1 = MatrixBytes::from_width_height(F32.into(), 16, 16).unwrap();
let planar = PlaneBytes::new([m0, m1]);
let ref_to_m0 = planar.plane_ref(0).unwrap();
let ref_to_m1 = planar.plane_ref(1).unwrap();
assert!(ref_to_m0.byte_len() <= ref_to_m1.offset.get());
assert!(ref_to_m1.byte_len() == planar.byte_len());Implementations§
Source§impl<const N: usize> PlaneBytes<N>
impl<const N: usize> PlaneBytes<N>
Sourcepub fn new(inner: [MatrixBytes; N]) -> Self
pub fn new(inner: [MatrixBytes; N]) -> Self
Construct from separate matrices.
Relocates each consecutive matrix such that they do not overlap.
§Panics
This method panics if the overall layout length would exceed isize::MAX.
pub fn from_repeated(matrix: MatrixBytes) -> Self
Sourcepub fn plane_ref(&self, idx: usize) -> Option<&Relocated<MatrixBytes>>
pub fn plane_ref(&self, idx: usize) -> Option<&Relocated<MatrixBytes>>
Return a reference to one relocated matrix layout.
Sourcepub fn retain_coefficients_like(&self, texel: TexelLayout) -> Self
pub fn retain_coefficients_like(&self, texel: TexelLayout) -> Self
Return a layout where only planes with a matching texel layout are preserved.
All other planes are rewritten to be empty matrices of that layout. All offsets are preserved.
use image_texel::texels::{U8, F32};
use image_texel::layout::{Layout, PlaneBytes, MatrixBytes};
let m0 = MatrixBytes::from_width_height(U8.into(), 4, 4).unwrap();
let m1 = MatrixBytes::from_width_height(F32.into(), 16, 16).unwrap();
let planar = PlaneBytes::new([m0, m1]);
let only_u8 = planar.retain_coefficients_like(U8.into());
assert_eq!(planar.plane_ref(0), only_u8.plane_ref(0));
assert_ne!(planar.plane_ref(1), only_u8.plane_ref(1));
use image_texel::layout::Relocate;
// That second plane is still offset, but empty
assert!(only_u8.plane_ref(1).unwrap().byte_len() > 0);
assert_eq!(only_u8.plane_ref(1).unwrap().byte_range().len(), 0);Trait Implementations§
Source§impl<const N: usize> Clone for PlaneBytes<N>
impl<const N: usize> Clone for PlaneBytes<N>
Source§fn clone(&self) -> PlaneBytes<N>
fn clone(&self) -> PlaneBytes<N>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T, const N: usize> Decay<PlaneMatrices<T, N>> for PlaneBytes<N>
impl<T, const N: usize> Decay<PlaneMatrices<T, N>> for PlaneBytes<N>
fn decay(from: PlaneMatrices<T, N>) -> PlaneBytes<N>
Source§impl<const N: usize> Relocate for PlaneBytes<N>
impl<const N: usize> Relocate for PlaneBytes<N>
Source§fn byte_offset(&self) -> usize
fn byte_offset(&self) -> usize
The offset of the first relevant byte of this layout. Read more
Source§fn relocate(&mut self, offset: AlignedOffset)
fn relocate(&mut self, offset: AlignedOffset)
Move the layout to another aligned offset. Read more
Source§fn relocate_to_byte(&mut self, offset: usize) -> bool
fn relocate_to_byte(&mut self, offset: usize) -> bool
Attempt to relocate the offset to another start offset, in bytes. Read more
Source§fn byte_range(&self) -> Range<usize>
fn byte_range(&self) -> Range<usize>
Retrieve the contiguous byte range occupied by this layout.
Auto Trait Implementations§
impl<const N: usize> Freeze for PlaneBytes<N>
impl<const N: usize> RefUnwindSafe for PlaneBytes<N>
impl<const N: usize> Send for PlaneBytes<N>
impl<const N: usize> Sync for PlaneBytes<N>
impl<const N: usize> Unpin for PlaneBytes<N>
impl<const N: usize> UnsafeUnpin for PlaneBytes<N>
impl<const N: usize> UnwindSafe for PlaneBytes<N>
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
Mutably borrows from an owned value. Read more