Function libxivdat::xiv_macro::as_writeable_bytes [−][src]
pub fn as_writeable_bytes(macros: &[MacroData<'_>]) -> Result<Vec<u8>, DATError>
Expand description
Returns a byte vector representing a slice of MacroData
. 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::{as_writeable_bytes, MacroData}; use libxivdat::xiv_macro::icon::MacroIcon; let macro_vec = vec![MacroData::new("Title", vec!["line"; 15], &MacroIcon::DefaultIcon).unwrap(); 100]; let macro_bytes = as_writeable_bytes(¯o_vec); assert!(macro_bytes.is_ok());