AdtError

Enum AdtError 

Source
pub enum AdtError {
Show 17 variants Io(Error), InvalidMagic { expected: ChunkId, found: ChunkId, offset: u64, }, MissingRequiredChunk(ChunkId), InvalidChunkCombination { chunk1: ChunkId, chunk2: ChunkId, }, OffsetOutOfBounds { chunk: ChunkId, offset: u32, file_position: u64, }, InvalidChunkSize { chunk: ChunkId, expected: usize, actual: usize, }, InvalidSubchunkOffset { parent: ChunkId, offset: u32, chunk_size: u32, }, InvalidWaterStructure(String), InvalidTextureReference { index: u32, count: u32, }, InvalidModelReference { index: u32, count: u32, }, InvalidMcinEntry { index: usize, }, ChunkParseError { chunk: ChunkId, offset: u64, details: String, }, BinrwError(String), Utf8Error(String), UnknownChunk { magic: [u8; 4], offset: u64, }, MemoryLimitExceeded { requested: usize, limit: usize, }, VersionDetectionFailed(String),
}
Expand description

Errors that can occur during ADT file parsing and validation.

This enum uses the fail-fast strategy: parsing halts at the first critical error. This prevents cascading failures and ensures that subsequent operations don’t work with corrupted or incomplete data.

Variants§

§

Io(Error)

Underlying I/O error occurred while reading ADT file.

This is a critical error that halts parsing immediately.

§

InvalidMagic

Chunk magic bytes don’t match expected format specification.

This is a critical error indicating the file is corrupted or not a valid ADT.

§Example

Expected MCNK chunk at offset 0x1000, but found MCLQ instead.

Fields

§expected: ChunkId

Expected chunk identifier.

§found: ChunkId

Actual chunk identifier found in file.

§offset: u64

File offset where invalid magic was encountered.

§

MissingRequiredChunk(ChunkId)

Required chunk is missing from ADT file.

This is a critical error. ADT files must contain certain chunks (MVER, MHDR, MCIN, MCNK) to be considered valid.

§Example

ADT file is missing required MHDR chunk - cannot parse terrain metadata.
§

InvalidChunkCombination

Mutually exclusive chunks are present in the same file.

This is a critical error. Some chunks cannot coexist because they represent incompatible format versions or conflicting data structures.

§Example

File contains both MCLQ (old water) and MH2O (new water) chunks.

Fields

§chunk1: ChunkId

First conflicting chunk.

§chunk2: ChunkId

Second conflicting chunk.

§

OffsetOutOfBounds

Chunk offset exceeds file boundaries.

This is a critical error indicating corrupted offset data or truncated file.

§Example

MCIN entry references MCNK at offset 0x50000, but file is only 0x40000 bytes.

Fields

§chunk: ChunkId

Chunk being accessed.

§offset: u32

Offset value that exceeds bounds.

§file_position: u64

File position where invalid offset was read.

§

InvalidChunkSize

Chunk size doesn’t match format specification.

This is a critical error. Fixed-size chunks must have exact expected sizes.

§Example

MVER chunk must be exactly 4 bytes, found 8 bytes instead.

Fields

§chunk: ChunkId

Chunk with invalid size.

§expected: usize

Expected size in bytes.

§actual: usize

Actual size in bytes.

§

InvalidSubchunkOffset

Subchunk offset exceeds parent chunk boundaries.

This is a critical error. Subchunk offsets must be relative to parent chunk start and cannot exceed parent chunk size.

§Example

MCNK subchunk offset 0x2000 exceeds MCNK chunk size of 0x1FC0.

Fields

§parent: ChunkId

Parent chunk containing the subchunk.

§offset: u32

Subchunk offset that exceeds bounds.

§chunk_size: u32

Total size of parent chunk.

§

InvalidWaterStructure(String)

Water data structure is malformed or contains invalid data.

This is a critical error for tiles with water features.

§Example

MH2O chunk has water layers but missing height data.
§

InvalidTextureReference

Texture index exceeds available texture count.

This is a critical error. All texture references must be valid indices into the texture list defined in MTEX chunk.

§Example

Layer references texture index 15, but only 10 textures are defined in MTEX.

Fields

§index: u32

Invalid texture index.

§count: u32

Total number of available textures.

§

InvalidModelReference

Model index exceeds available model count.

This is a critical error. All model references must be valid indices into the model lists defined in MMDX/MMID or MWMO/MWID chunks.

§Example

MCRF references M2 model index 50, but only 30 models defined in MMDX.

Fields

§index: u32

Invalid model index.

§count: u32

Total number of available models.

§

InvalidMcinEntry

MCIN entry references non-existent MCNK chunk.

This is a critical error. MCIN (chunk index) entries must reference valid MCNK chunks. ADT files should have exactly 256 MCNK chunks (16x16 grid).

§Example

MCIN entry 100 has non-zero offset but corresponding MCNK chunk is missing.

Fields

§index: usize

Index of invalid MCIN entry.

§

ChunkParseError

Generic chunk parsing error with context.

This is a critical error used when more specific error types don’t apply.

§Example

Failed to parse MCLY chunk at offset 0x3000: layer count mismatch.

Fields

§chunk: ChunkId

Chunk that failed to parse.

§offset: u64

File offset where error occurred.

§details: String

Detailed error description.

§

BinrwError(String)

Binary parsing library error.

This is a critical error from the underlying binrw library.

§

Utf8Error(String)

UTF-8 conversion error encountered in string data.

This is a WARNING, not a critical error. When invalid UTF-8 is encountered, lossy conversion is applied (invalid sequences replaced with �) and parsing continues.

§Example

Texture filename contains invalid UTF-8 byte 0xFF, using lossy conversion.
§

UnknownChunk

Unknown chunk encountered during parsing.

This is a WARNING, not a critical error. Unknown chunks are skipped and parsing continues. This allows for forward compatibility with newer ADT format versions.

§Example

Unknown chunk 'MXYZ' at offset 0x5000, skipping to next chunk.

Fields

§magic: [u8; 4]

Raw magic bytes of unknown chunk.

§offset: u64

File offset where unknown chunk was found.

§

MemoryLimitExceeded

Memory allocation exceeds safety limits.

This is a critical error to prevent memory exhaustion attacks from malicious or corrupted files claiming enormous allocation sizes.

§Example

Chunk claims to need 2GB allocation, exceeds 100MB limit.

Fields

§requested: usize

Number of bytes requested.

§limit: usize

Maximum allowed allocation size.

§

VersionDetectionFailed(String)

Cannot determine ADT format version.

This is a critical error. Version detection is required to parse format-specific chunks.

§Example

MVER chunk contains unknown version 19, expected 18 (WotLK).

Trait Implementations§

Source§

impl Debug for AdtError

Source§

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

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

impl Display for AdtError

Source§

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

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

impl Error for AdtError

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<Error> for AdtError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for AdtError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.

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> CustomError for T
where T: Display + Debug + Send + Sync + 'static,

Source§

fn as_any(&self) -> &(dyn Any + Sync + Send + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + Sync + Send + 'static)

Source§

fn as_box_any(self: Box<T>) -> Box<dyn Any + Sync + Send>

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> 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.