pub trait CoverSource {
// Required methods
fn dimensions(&self) -> (u32, u32);
fn pixels(&self) -> &[u8] ⓘ;
fn pixels_mut(&mut self) -> &mut [u8] ⓘ;
fn color_space(&self) -> ColorSpace;
// Provided methods
fn pixel_count(&self) -> usize { ... }
fn pixel_offset(&self, x: u32, y: u32) -> usize { ... }
}Expand description
Read/write access to the raw samples of a container image.
The trait exists so that the cost and embedding layers can operate on any
pixel source without owning the concrete buffer type. Implementors must
guarantee that CoverSource::pixels holds exactly
pixel_count() * color_space().bytes_per_pixel() elements, laid out in
row-major order with no padding between rows.
Required Methods§
Sourcefn dimensions(&self) -> (u32, u32)
fn dimensions(&self) -> (u32, u32)
Image dimensions as (width, height), in pixels.
Sourcefn pixels_mut(&mut self) -> &mut [u8] ⓘ
fn pixels_mut(&mut self) -> &mut [u8] ⓘ
Mutable view of the raw sample bytes, used by the embedding layer.
Sourcefn color_space(&self) -> ColorSpace
fn color_space(&self) -> ColorSpace
Pixel layout of the underlying samples.
Provided Methods§
Sourcefn pixel_count(&self) -> usize
fn pixel_count(&self) -> usize
Total number of pixels in the image.
Sourcefn pixel_offset(&self, x: u32, y: u32) -> usize
fn pixel_offset(&self, x: u32, y: u32) -> usize
Byte offset of the first sample of the pixel at (x, y).
The coordinates are not bounds-checked; callers must keep them inside
the range reported by CoverSource::dimensions.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".