Skip to main content

read_tlk_from_bytes

Function read_tlk_from_bytes 

Source
pub fn read_tlk_from_bytes(bytes: &[u8]) -> Result<Tlk, TlkBinaryError>
Expand description

Reads a TLK from in-memory bytes.

§Errors

TlkBinaryError::InvalidMagic when the signature is not TLK , and TlkBinaryError::InvalidVersion for a version other than V3.0.

TlkBinaryError::InvalidHeader when the header is truncated or an entry’s string offset and length run past the end of bytes. TlkBinaryError::UnsupportedLanguageEncoding when the header’s language id maps to no codepage, and TlkBinaryError::TextDecoding when an entry’s text is not valid in that codepage.

TlkBinaryError::InvalidSoundResRef for an entry’s sound resref that is not a valid one. The language id is read from the header, so one bad id fails the whole table rather than a single entry.