pub trait ImageCodecs {
// Required methods
fn decoded_formats(&self) -> Vec<String>;
fn encoded_formats(&self) -> Vec<String>;
fn open(&self, data: Arc<[u8]>) -> ImageFuture<Box<dyn ImageSource>>;
fn open_file(&self, path: &Path) -> ImageFuture<Box<dyn ImageSource>>;
fn encode_pixels(
&self,
pixels: PixelBuffer,
format: &str,
quality: Option<f32>,
) -> ImageFuture<Vec<u8>>;
fn hardware_image_codecs(&self) -> Option<&dyn HardwareImageCodecs>;
}Expand description
The system’s image codecs, or None from
Platform::image_codecs where it has none.
Required Methods§
Sourcefn decoded_formats(&self) -> Vec<String>
fn decoded_formats(&self) -> Vec<String>
The formats it decodes, by MIME type, such as image/jpeg.
Sourcefn encoded_formats(&self) -> Vec<String>
fn encoded_formats(&self) -> Vec<String>
The formats it encodes, by MIME type.
Sourcefn open(&self, data: Arc<[u8]>) -> ImageFuture<Box<dyn ImageSource>>
fn open(&self, data: Arc<[u8]>) -> ImageFuture<Box<dyn ImageSource>>
The image data encodes, read as far as its size, pictures, orientation and metadata:
ImageErrorKind::Unsupported for bytes of no format it decodes,
ImageErrorKind::Damaged for bytes it cannot read that far.
Sourcefn open_file(&self, path: &Path) -> ImageFuture<Box<dyn ImageSource>>
fn open_file(&self, path: &Path) -> ImageFuture<Box<dyn ImageSource>>
The image in the file at path, which the system reads only as far as it needs, as a
photo’s metadata or the small picture it carries: ImageErrorKind::NotFound for a path
with no file.
Sourcefn encode_pixels(
&self,
pixels: PixelBuffer,
format: &str,
quality: Option<f32>,
) -> ImageFuture<Vec<u8>>
fn encode_pixels( &self, pixels: PixelBuffer, format: &str, quality: Option<f32>, ) -> ImageFuture<Vec<u8>>
pixels encoded in format, one of the encoded_formats, at
quality from 0.0, the smallest, to 1.0, the best, where the format loses detail, or
the system’s own where None: ImageErrorKind::Unsupported for a format it does not
encode.
Sourcefn hardware_image_codecs(&self) -> Option<&dyn HardwareImageCodecs>
fn hardware_image_codecs(&self) -> Option<&dyn HardwareImageCodecs>
The system’s hardware codecs, or None where it neither decodes into hardware buffers
nor encodes from them.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".