Module chunk

Module chunk 

Source
Expand description

This modules provides utilities to read and write VOX files as chunks, but is agnostic to the content of these chunks.

VOX files use a binary format that is similar to that of RIFF files. Unfortunately it’s different enough that the riff crate can’t be used.

The file format consists of so-called chunks, which contain specific data (e.g. palette data). Chunks have IDs consisting of 4 bytes. A file starts with a root-chunk MAIN. The MAIN chunk then contains other chunks that contain the voxel data. The format is specified here, but not all chunk IDs are described.

Structs§

ChildrenReader
An iterator over a chunk’s children.
Chunk
Chunk meta-data. This doesn’t contain contents or children, but information needed to read the chunk from a file. You will still need a reader to read the contents though.
ChunkIdParseError
ChunkWriter
This struct is used to write out chunks to a file.
ContentReader
A reader for a chunk’s contents.
ContentWriter
This implements Write and Seek on a restricted range of offsets in the underlying reader of the chunk you’re writing to.

Enums§

ChunkId
A chunk ID. It’s either a pre-defined ID (that is used for VOX), or Unsupported.

Functions§

chunk_writer
This creates a ChunkWriter and will the closure you passed in with it. This allows you to write contents and children to the ChunkWriter. After you return from the closure this function will make sure that the chunk headers are upates.
read_chunk_at
Reads a chunk from reader at the specified offset.
read_main_chunk
Reads the VOX file’s header, verifies it, and then reads the MAIN chunk.

Type Aliases§

ChildWriter
Short-hand for a ChunkWriter wrapping a ContentWriter. The underlying content-writer writes to the chunk’s children data blob.