Function libxivdat::xiv_macro::read_macro[][src]

pub fn read_macro(dat_file: &mut DATFile) -> Result<Macro, DATError>
Expand description

Reads the next Macro from a DATFile.

Errors

Returns DATError::IncorrectType if the file appears to be of a type other than DATType::Macro.

If an I/O error occurs while reading the file, a DATError::FileIO error will be returned wrapping the underlying FS error.

If the macro title or lines do not contain valid utf-8, a DATError::BadEncoding error will be returned.

Examples

use libxivdat::dat_file::DATFile;
use libxivdat::xiv_macro::read_macro;
use libxivdat::xiv_macro::icon::MacroIcon;

let mut dat_file = DATFile::open("./resources/TEST_MACRO.DAT").unwrap();
let a_macro = read_macro(&mut dat_file).unwrap();

assert_eq!(a_macro.title, "0");
assert_eq!(a_macro.lines[0], "DefaultIcon");
assert_eq!(a_macro.get_icon().unwrap(), MacroIcon::DefaultIcon);