Trait show_image::ImageData[][src]

pub trait ImageData {
    fn data(self) -> Box<[u8]>;
fn info(&self) -> Result<ImageInfo, String>; fn into_image_tuple(self) -> Result<(Box<[u8]>, ImageInfo), String>
    where
        Self: Sized
, { ... } }

Allows a type to be displayed as an image.

This trait is implemented for tuples of (Data, ImageInfo) if Data can be converted into a Box<[u8]>, and for &(Data, ImageInfo) if Data is AsRef<[u8]>. Amongst others, that includes &[u8], Box<[u8]>, Vec<u8>.

Implementations for types from third-party libraries can be enabled using feature flags.

Required methods

fn data(self) -> Box<[u8]>[src]

Get the image data as boxed slice.

This function takes self by value to prevent copying if possible. If the data can not be moved into a box, consider implementing the trait for references.

fn info(&self) -> Result<ImageInfo, String>[src]

Get the ImageInfo describing the binary data.

This function may fail at runtime if the data can not be described properly.

Loading content...

Provided methods

fn into_image_tuple(self) -> Result<(Box<[u8]>, ImageInfo), String> where
    Self: Sized
[src]

Convert the image into a tuple containing the image info and data.

Loading content...

Implementations on Foreign Types

impl ImageData for DynamicImage[src]

impl ImageData for &DynamicImage[src]

impl<P> ImageData for ImageBuffer<P, Vec<u8>> where
    P: Pixel<Subpixel = u8> + 'static, 
[src]

impl<P> ImageData for &ImageBuffer<P, Vec<u8>> where
    P: Pixel<Subpixel = u8> + 'static, 
[src]

impl ImageData for DrawTarget[src]

impl ImageData for &DrawTarget[src]

impl<'a> ImageData for Image<'a>[src]

impl<'a> ImageData for &Image<'a>[src]

impl ImageData for Result<TensorImage<'_>, String>[src]

impl<Container> ImageData for (Container, ImageInfo) where
    Box<[u8]>: From<Container>, 
[src]

impl<Container> ImageData for (Container, &ImageInfo) where
    Box<[u8]>: From<Container>, 
[src]

impl<Container> ImageData for &(Container, ImageInfo) where
    Container: AsRef<[u8]>, 
[src]

impl<Container> ImageData for &(Container, &ImageInfo) where
    Container: AsRef<[u8]>, 
[src]

Loading content...

Implementors

impl ImageData for TensorImage<'_>[src]

Loading content...