Function libxivdat::xiv_macro::to_writeable_bytes[][src]

pub fn to_writeable_bytes(macros: &[Macro]) -> Result<Vec<u8>, DATError>
Expand description

Returns a byte vector representing a slice of Macros. This can then be written back to a a file using write_content(). This function validates each macro. Additionally, the slice will be padded with empty macros to 100 (EXPECTED_ITEM_COUNT) items if it is shorter.

Errors

Returns DATError::Overflow if a macro data section would exceed the maximum possible size for that section type, or if the slice contains more than EXPECTED_ITEM_COUNT macros.

Returns any validation errors returned by validate().

Examples

use libxivdat::xiv_macro::{to_writeable_bytes, Macro};
use libxivdat::xiv_macro::icon::MacroIcon;

let macro_vec = vec![Macro::new("Title".to_owned(), vec!["line".to_owned(); 15], MacroIcon::DefaultIcon).unwrap(); 100];
let macro_bytes = to_writeable_bytes(&macro_vec);
assert!(macro_bytes.is_ok());