Skip to main content

ConvertError

Enum ConvertError 

Source
#[non_exhaustive]
pub enum ConvertError {
Show 15 variants NoMatch { source: PixelDescriptor, }, NoPath { from: PixelDescriptor, to: PixelDescriptor, }, BufferSize { expected: usize, actual: usize, }, InvalidWidth(u32), EmptyFormatList, UnsupportedTransfer { from: TransferFunction, to: TransferFunction, }, AlphaNotOpaque, DepthReductionForbidden, AlphaRemovalForbidden, RgbToGray, AllocationFailed, Buffer(BufferError), CmsError(String), HdrSourceRequiresPeak { from: PixelDescriptor, to: PixelDescriptor, }, NeedsCms { from: PixelDescriptor, to: PixelDescriptor, },
}
Expand description

Errors that can occur during pixel format negotiation or conversion.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NoMatch

No supported format could be found for the source descriptor.

Fields

§

NoPath

No conversion path exists between the two formats.

§

BufferSize

Source and destination buffer sizes don’t match the expected dimensions.

Fields

§expected: usize
§actual: usize
§

InvalidWidth(u32)

Width is zero or would overflow stride calculations.

§

EmptyFormatList

The supported format list was empty.

§

UnsupportedTransfer

Conversion between these transfer functions is not yet supported.

§

AlphaNotOpaque

Alpha channel is not fully opaque and AlphaPolicy::DiscardIfOpaque was set.

§

DepthReductionForbidden

Depth reduction was requested but DepthPolicy::Forbid was set.

§

AlphaRemovalForbidden

Alpha removal was requested but AlphaPolicy::Forbid was set.

§

RgbToGray

RGB-to-grayscale conversion requires explicit luma coefficients.

§

AllocationFailed

Buffer allocation failed.

§

Buffer(BufferError)

A pixel buffer or slice could not be constructed: carries the real zenpixels::BufferError cause (StrideTooSmall, InvalidDimensions, …) instead of collapsing it into AllocationFailed.

§

CmsError(String)

CMS transform could not be built (invalid ICC profile, unsupported color space, etc.).

§

HdrSourceRequiresPeak

The conversion is HDR (Pq / Hlg) → SDR but no usable peak luminance was supplied. Raised both when no peak was given at all (the plain ConvertPlan::new entry point doesn’t take one) and when a supplied HdrConfig carries a non-finite or non-positive source_peak_nits / target_peak_nits (including the unset HdrConfig::default() value 0.0) — a degenerate peak would tone-map every pixel to black. Build the plan via ConvertPlan::new_with_hdr_peak (or ConvertPlan::new_with_hdr_config for full knob control), and pass the source’s MaxCLL — e.g. from hdr::measure::CllMeasure::measure_max. All three live behind the hdr-experimental Cargo feature (plain code spans here, not intra-doc links, so this page renders link-clean without it).

Pre-0.2.16 the plain ConvertPlan::new silently routed HDR→SDR through the linear intermediate with no tone-mapping, producing semantically wrong pixels. This variant replaces that with a loud refusal.

§

NeedsCms

The conversion requires a color management plugin but none was provided.

Returned when one (or both) sides use a non-native color model — CMYK, Lab, XYZ, spot inks, or any future device-dependent space — that zenpixels-convert cannot resolve with its built-in kernels. Attach a plugin via RowConverter::new_explicit_with_cms (e.g. Some(&MoxCms) under the cms-moxcms feature) and the plan will dispatch the full row work to it.

Distinct from NoPath: NeedsCms says “a path exists, but requires CMS dispatch”; NoPath says “no architecturally possible conversion.” Callers that want to route to a CMS should match on NeedsCms and re-issue the call with a plugin attached.

Pre-0.2.16: the same descriptors caused a process-aborting assert_not_cmyk panic — replaced by this typed variant so the documented Some(&MoxCms) escape hatch is actually reachable.

Trait Implementations§

Source§

impl Clone for ConvertError

Source§

fn clone(&self) -> ConvertError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConvertError

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for ConvertError

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Error for ConvertError

Available on crate feature std only.
1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<BufferError> for ConvertError

Source§

fn from(err: BufferError) -> Self

Wrap a buffer-construction failure’s real cause into ConvertError::Buffer. Pair with map_err_at at the call sites so the At location trace is preserved alongside the classified cause.

Source§

impl PartialEq for ConvertError

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ConvertError

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<E> ErrorAtExt for E
where E: Error,

Source§

fn start_at(self) -> At<E>

Wrap this value in At<E> and add the caller’s location. If allocation fails, the error is still wrapped but trace may be empty. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.