Function libxivdat::xiv_macro::as_macro_vec [−][src]
pub fn as_macro_vec(bytes: &[u8]) -> Result<Vec<MacroData<'_>>, DATError>
Expand description
Interprets a byte slice as a block of MacroData
, returning a Vec
of them.
Errors
Returns a DATError::Overflow
or DATError::Underflow
if
a macro section has a length that does not match the length specified in its header.
If a macro section does not have valid utf-8 content, a DATError::BadEncoding
error will be returned.
Examples
use libxivdat::dat_file::read_content; use libxivdat::xiv_macro::{as_macro_vec, read_macro_content}; use libxivdat::xiv_macro::icon::MacroIcon; let content_bytes = read_content("./resources/TEST_MACRO.DAT").unwrap(); let macro_data_vec = as_macro_vec(&content_bytes).unwrap(); assert_eq!(macro_data_vec[0].title, "0"); assert_eq!(macro_data_vec[0].lines[0], "DefaultIcon"); assert_eq!(macro_data_vec[0].get_icon().unwrap(), MacroIcon::DefaultIcon); assert_eq!(macro_data_vec[1].title, "1"); assert_eq!(macro_data_vec[1].lines[0], "DPS1"); assert_eq!(macro_data_vec[1].get_icon().unwrap(), MacroIcon::DPS1);