Enum CropResult

#[must_use]
pub enum CropResult<Cropped, Old>

Cropping an image fails if the image is fully transparent. Use or_crop_to_1x1_if_empty or or_none_if_empty to obtain a normal image again.

Variants

Cropped(Cropped)

The image contained some pixels and has been cropped or left untouched

Empty { original: Old }

All pixels in the image would be discarded, removing the whole image

Implementations

impl<Cropped, Original> CropResult<Cropped, Original>

fn or_none_if_empty(self) -> Option<Cropped>

If the image was fully empty, return None, otherwise return Some(cropped_image).

fn or_crop_to_1x1_if_empty(self) -> Cropped
where
    Original: Crop<Cropped = Cropped> + GetBounds,

If the image was fully empty, crop to one single pixel of all the transparent pixels instead, leaving the layer intact while reducing memory usage.

Panics

Panics if the layer has zero width and height (which indicates an invalid layer state). This should never happen with properly constructed images.

Trait Implementations

impl<Cropped: Clone, Old: Clone> Clone for CropResult<Cropped, Old>

fn clone(&self) -> Self

impl<Cropped: Copy, Old: Copy> Copy for CropResult<Cropped, Old>

impl<Cropped: Debug, Old: Debug> Debug for CropResult<Cropped, Old>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<Cropped: Eq, Old: Eq> Eq for CropResult<Cropped, Old>

impl<Cropped: PartialEq, Old: PartialEq> PartialEq for CropResult<Cropped, Old>

fn eq(&self, other: &Self) -> bool

impl<Cropped: PartialEq, Old: PartialEq> StructuralPartialEq for CropResult<Cropped, Old>

Auto Trait Implementations

impl<Cropped, Old> Freeze for CropResult<Cropped, Old> where Cropped: Freeze, Old: Freeze,

impl<Cropped, Old> RefUnwindSafe for CropResult<Cropped, Old> where Cropped: RefUnwindSafe, Old: RefUnwindSafe,

impl<Cropped, Old> Send for CropResult<Cropped, Old> where Cropped: Send, Old: Send,

impl<Cropped, Old> Sync for CropResult<Cropped, Old> where Cropped: Sync, Old: Sync,

impl<Cropped, Old> Unpin for CropResult<Cropped, Old> where Cropped: Unpin, Old: Unpin,

impl<Cropped, Old> UnsafeUnpin for CropResult<Cropped, Old> where Cropped: UnsafeUnpin, Old: UnsafeUnpin,

impl<Cropped, Old> UnwindSafe for CropResult<Cropped, Old> where Cropped: UnwindSafe, Old: UnwindSafe,

Blanket Implementations

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for CropResult<Cropped, Old> where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for CropResult<Cropped, Old> where ST: ?Sized, DT: ?Sized,

impl<T> Any for CropResult<Cropped, Old> where T: 'static + ?Sized,

impl<T> Borrow<T> for CropResult<Cropped, Old> where T: ?Sized,

impl<T> BorrowMut<T> for CropResult<Cropped, Old> where T: ?Sized,

impl<T> CloneToUninit for CropResult<Cropped, Old> where T: Clone,

impl<T> From<T> for CropResult<Cropped, Old>

impl<T> Pointable for CropResult<Cropped, Old>

impl<T> Read<Exclusive, BecauseExclusive> for CropResult<Cropped, Old> where T: ?Sized,

impl<T> ToOwned for CropResult<Cropped, Old> where T: Clone,

impl<T, U> Into<U> for CropResult<Cropped, Old> where U: From<T>,

impl<T, U> TryFrom<U> for CropResult<Cropped, Old> where U: Into<T>,

impl<T, U> TryInto<U> for CropResult<Cropped, Old> where U: TryFrom<T>,