aboutsummaryrefslogtreecommitdiff
path: root/crates/texm/src/error.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-02-19 03:46:23 +0300
committerValentin Popov <valentin@popov.link>2026-02-19 03:46:23 +0300
commit0e19660eb5122c8c52d5e909927884ad5c50b813 (patch)
tree6a53c24544ca828f08c2b6872d568b1edc1a4cef /crates/texm/src/error.rs
parent8a69872576eed41a918643be52a80fe74a054974 (diff)
downloadfparkan-0e19660eb5122c8c52d5e909927884ad5c50b813.tar.xz
fparkan-0e19660eb5122c8c52d5e909927884ad5c50b813.zip
Refactor documentation structure and add new specifications
- Updated MSH documentation to reflect changes in material, wear, and texture specifications. - Introduced new `render.md` file detailing the render pipeline process. - Removed outdated sections from `runtime-pipeline.md` and redirected to `render.md`. - Added detailed specifications for `Texm` texture format and `WEAR` wear table. - Updated navigation in `mkdocs.yml` to align with new documentation structure.
Diffstat (limited to 'crates/texm/src/error.rs')
-rw-r--r--crates/texm/src/error.rs61
1 files changed, 61 insertions, 0 deletions
diff --git a/crates/texm/src/error.rs b/crates/texm/src/error.rs
new file mode 100644
index 0000000..a5dda77
--- /dev/null
+++ b/crates/texm/src/error.rs
@@ -0,0 +1,61 @@
+use core::fmt;
+
+#[derive(Debug)]
+pub enum Error {
+ HeaderTooSmall {
+ size: usize,
+ },
+ InvalidMagic {
+ got: u32,
+ },
+ InvalidDimensions {
+ width: u32,
+ height: u32,
+ },
+ InvalidMipCount {
+ mip_count: u32,
+ },
+ UnknownFormat {
+ format: u32,
+ },
+ IntegerOverflow,
+ CoreDataOutOfBounds {
+ expected_end: usize,
+ actual_size: usize,
+ },
+ InvalidPageMagic,
+ InvalidPageSize {
+ expected: usize,
+ actual: usize,
+ },
+}
+
+impl fmt::Display for Error {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ Self::HeaderTooSmall { size } => {
+ write!(f, "Texm payload too small for header: {size}")
+ }
+ Self::InvalidMagic { got } => write!(f, "invalid Texm magic: 0x{got:08X}"),
+ Self::InvalidDimensions { width, height } => {
+ write!(f, "invalid Texm dimensions: {width}x{height}")
+ }
+ Self::InvalidMipCount { mip_count } => write!(f, "invalid Texm mip_count={mip_count}"),
+ Self::UnknownFormat { format } => write!(f, "unknown Texm format={format}"),
+ Self::IntegerOverflow => write!(f, "integer overflow"),
+ Self::CoreDataOutOfBounds {
+ expected_end,
+ actual_size,
+ } => write!(
+ f,
+ "Texm core data out of bounds: expected_end={expected_end}, actual_size={actual_size}"
+ ),
+ Self::InvalidPageMagic => write!(f, "Texm tail exists but Page magic is missing"),
+ Self::InvalidPageSize { expected, actual } => {
+ write!(f, "invalid Page chunk size: expected={expected}, actual={actual}")
+ }
+ }
+ }
+}
+
+impl std::error::Error for Error {}