[][src]Trait show_image::ImageData

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

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]>

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>

Get the ImageInfo describing the binary data.

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

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 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...