1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
pub type Result<T> = std::result::Result<T, Error>;
/// Errors produced anywhere in the ctt pipeline.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Image dimensions are zero, negative, or otherwise invalid for the operation.
#[error("invalid dimensions: {0}")]
InvalidDimensions(String),
/// The pixel format is not supported by the requested operation or container.
#[error("unsupported format: {0}")]
UnsupportedFormat(String),
/// A swizzle specification is malformed or references invalid channels.
#[error("invalid swizzle: {0}")]
InvalidSwizzle(String),
/// A cubemap was given a number of faces that is not exactly 6 (per cube).
#[error("cubemap requires exactly 6 faces, got {0}")]
CubemapFaceCount(usize),
/// The faces of a cubemap do not all share the same dimensions.
#[error("cubemap faces must have uniform dimensions")]
CubemapNonUniformFaces,
/// Block or supercompression of image data failed.
#[error("compression failed: {0}")]
Compression(String),
/// Serializing an [`Image`](crate::surface::Image) into a container failed.
#[error("output encoding error: {0}")]
OutputEncoding(String),
/// Parsing or decoding an input container (KTX2/DDS) failed, including
/// malformed, truncated, or maliciously crafted headers.
#[error("input decoding error: {0}")]
InputDecoding(String),
/// A buffer's length did not match the size implied by its format and dimensions.
#[error("data length mismatch: expected {expected}, got {actual}")]
DataLengthMismatch { expected: usize, actual: usize },
/// No conversion path exists between the source and destination pixel formats.
#[error("unsupported pixel format conversion: {0}")]
UnsupportedConversion(String),
/// A transform would require a lossy automatic format conversion that was not permitted.
#[error(
"lossy auto-conversion from {from} to {to} required by transform '{transform}': {reason}"
)]
LossyConversion {
/// The source format the conversion would start from.
from: String,
/// The destination format the conversion would produce.
to: String,
/// The transform that triggered the conversion requirement.
transform: String,
/// Why the conversion is considered lossy.
reason: String,
},
/// The image failed a structural validity check (e.g. inconsistent surfaces).
#[error("invalid image: {0}")]
InvalidImage(String),
}