Function libxivdat::section::as_section_vec[][src]

pub fn as_section_vec<'a>(
    bytes: &'a [u8]
) -> Result<Vec<SectionData<'a>>, DATError>
Expand description

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

Errors

Returns a DATError::Overflow or DATError::Underflow if a section content block does not match the expected length specified in the section header.

If the tag or content is not valid utf8 text, a DATError::BadEncoding error will be returned.

Examples

use libxivdat::dat_file::read_content;
use libxivdat::section::as_section_vec;

let content_bytes = read_content("./resources/TEST_SECTION.DAT").unwrap();
let section = as_section_vec(&content_bytes).unwrap();

assert_eq!(section[0].tag, "T");
assert_eq!(section[0].content_size, 24);
assert_eq!(section[0].content, "This is a test section.");

assert_eq!(section[1].tag, "A");
assert_eq!(section[1].content_size, 22);
assert_eq!(section[1].content, "Another test section.");