#[non_exhaustive]pub enum ImageData<'a> {
Borrowed(&'a [u8]),
BorrowedColors(&'a [Color]),
Owned(Vec<u8>),
Asset(AssetHandle),
}Expand description
Pixel storage owned by or borrowed by an ImageDescriptor.
The enum is non-exhaustive so future asset-handle sources can be added without breaking callers. Consumers should include a wildcard arm when matching.
§LPAR-09 addition
The ImageData::Asset variant bridges source-backed images (registered
with an AssetRegistry) into the image pipeline. Decoded pixels may or
may not be resident in the cache; callers MUST call
AssetRegistry::resolve_image before blitting to ensure decoded data is
present.
§Match exhaustiveness
Because ImageData is #[non_exhaustive], external match expressions
already require a wildcard arm. The addition of Asset is non-breaking.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Borrowed(&'a [u8])
Borrowed encoded pixel bytes in the descriptor’s PixelFormat.
BorrowedColors(&'a [Color])
Borrowed Color pixels used as a safe zero-copy ARGB8888 bridge.
This avoids casting Color values to raw bytes; consumers that need
packed bytes can serialize each color with Color::to_argb8888.
Owned(Vec<u8>)
Heap-resident encoded pixel bytes in the descriptor’s PixelFormat.
Asset(AssetHandle)
fs only.Source-backed image handle registered with an AssetRegistry.
The decoded pixels may or may not be resident in the SlotCache at
any moment. Callers MUST call AssetRegistry::resolve_image(handle) to
obtain a descriptor with in-memory pixel data before blitting.
Added by LPAR-09 (Standards Action; LPAR-08 §15 amendment filed
2026-06-12). Ownership of the AssetPath behind this handle lives in
the AssetRegistry, enabling reload after cache eviction.
Implementations§
Source§impl<'a> ImageData<'a>
impl<'a> ImageData<'a>
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Return the encoded byte length represented by this data source.
ImageData::BorrowedColors reports colors.len() * 4 because each
color is represented as one ARGB8888 pixel.
ImageData::Asset returns 0 because decoded pixels are not
in-memory until AssetRegistry::resolve_image is called. This
follows LVGL’s model where an unresolved source has zero in-memory size.
Sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
Return borrowed encoded bytes when this source is byte-addressable.
ImageData::BorrowedColors and ImageData::Asset return None
because neither exposes in-memory bytes directly.
Sourcepub fn as_color_slice(&self) -> Option<&[Color]>
pub fn as_color_slice(&self) -> Option<&[Color]>
Return borrowed color pixels when this source is the safe color bridge.