Expand description
Full re-export of zenpixels core types (zero module name collisions!).
Alignment-exact, #![forbid(unsafe_code)] owned pixel storage.
§Allocation / deallocation alignment rules (bytemuck & GlobalAlloc)
Rust’s core::alloc::GlobalAlloc::dealloc requires every allocation to be
freed with the exact same Layout (byte capacity and alignment) that
allocated it. Therefore:
- A
Vec<u8>(align = 1) can never become aVec<u16>(align = 2) orVec<Rgb<u16>>(align = 2) without copying, even if glibc happens to return an even pointer. - Conversely,
Vec<Rgb<u16>>(align = 2, size = 6) can move zero-copy to and fromVec<u16>(align = 2, size = 2) via [bytemuck::allocation::try_cast_vec] whenever both length and capacity in bytes are multiples ofsize_of::<Rgb<u16>>()(6). AlignedSamplesallocatesVec<Chunk>with#[repr(C, align(64))], so its base address is always 64-byte aligned (divisible by1, 2, 4, 8, 16, 32, 64for zero-copy slice borrowing viabytemuck::cast_slice), and it always deallocates withalign = 64(never UB-cast toVec<u8>).- On 32-bit targets where
align_of::<u64>()may differ fromalign_of::<f64>(),F64checks exact alignment equality before casting.
Structs§
- Aligned
Samples - Owned byte storage whose first byte is guaranteed 64-byte aligned on every allocator.
- External
MutStorage - Type-erased mutable external owned backing storage (
Box<[T]>, custom-allocator wrappers, mutable pool leases, FFI writable buffers). - External
Storage - Type-erased immutable external owned backing storage (
Arc<[T]>,&'static [T], memory-mapped files, shared buffer pools, FFI read-only buffers).
Enums§
- Pixel
Storage - Alignment-exact owned pixel backing storage.
- Storage
Error - Low-level storage allocation error.
Traits§
- Byte
Storage - Read access to native-endian pixel bytes without copying.
- Byte
Storage Mut - Mutable access to native-endian pixel bytes without copying.
- Storage
Sample - Sealed trait implemented by the 11 native sample types stored in
PixelStorage.