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,

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

fn borrow_mut(&mut self) -> &mut T

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

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

fn from(t: T) -> T

Returns the argument unchanged.

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

const ALIGN: usize = _;
type Init = T;
unsafe fn init(init: <T as Pointable>::Init) -> usize
unsafe fn deref<'a>(ptr: usize) -> &'a T
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
unsafe fn drop(ptr: usize)

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

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

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

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>