Module libxivdat::section[][src]

Expand description

Contains a generic tool set for working with any section-based binary DAT files. This module contains two equivalent implementations: Section, read_section(), and read_section_content() for working with files on disk and SectionData, as_section(), and as_section_vec() for working with pre-allocated byte arrays.

Because sections are variable-length data structures, no functions for writing sections in-place are provided. The recommended approach to writing section-based files is to read the entire file, then write an entirely new content block with write_content().

Structs

A Section is variable-length data structure common to several binary DAT files. A Resource (ie, a Macro or Gearset) is then made out of a repeating pattern of sections. Section owns its constituent data and is returned from helper functions like read_section(). To build a section with refrences to a pre-allocated buffer, use SectionData.

A Section is variable-length data structure common to several binary DAT files. A Resource (ie, a Macro or Gearset) is then made out of a repeating pattern of sections. SectionData is used to build sections with references to pre-allocated buffers. To build a section that owns its own data, use Section.

Constants

Array of DATTypes that have Section-based contents. DATType::Unknown is allowed, since its contents are not known.

Length of a section header in bytes.

Functions

Interprets a byte slice as SectionData.

Interprets a byte slice as a block of SectionData, returning a Vec of them.

Tries to read a SECTION_HEADER_SIZE byte array as a Section header. Returns a tuple containing (tag, content_size).

Reads the next Section from a DATFile.

Reads all Sections from a specified DAT file, returning a Vec of them. This performs only one read operation on the underlying file, loading the entire content into memory to prevent repeat file access. This is similar to read_content(), but returns a Vec<Section> instead of raw bytes.

Reads all Sections from a specified DAT file, returning a Vec of them. This performs only one read operation on the underlying file, loading the entire content into memory to prevent repeat file access. This is similar to read_content(), but returns a Vec<Section> instead of raw bytes. This does not check that the file is of a type that should contain sections.

Reads the next Section from a DATFile. This does not check that the file is of a type that should contain sections.