Expand description
ZBI Processing Library
This library is meant to be a generic processing library for the ZBI format defined in sdk/lib/zbi-format/include/lib/zbi-format/zbi.h.
Mainly it provides ZbiContainer that can create (ZbiContainer::new) valid container in
the provided buffer. Or parses and checks (ZbiContainer::parse) existing container in the
buffer. In both cases it provides iterator to walk thorough the items in container.
Note: in both cases provided buffer must be properly aligned to ZBI_ALIGNMENT_USIZE.
Using align_buffer would do proper alignment for you.
use zbi::{ZbiContainer, ZbiFlags, ZbiType, align_buffer};
let mut buffer = [0; 200];
let mut buffer = align_buffer(&mut buffer[..]).unwrap();
let mut container = ZbiContainer::new(buffer).unwrap();
container.create_entry(ZbiType::DebugData, 0, ZbiFlags::default(), 10).unwrap();
container.create_entry_with_payload(ZbiType::DebugData, 0, ZbiFlags::default(), &[]).unwrap();
assert_eq!(container.iter().count(), 2);
let mut it = container.iter();
assert_eq!(it.next().unwrap().header.length, 10);
assert_eq!(it.next().unwrap().header.length, 0);
assert_eq!(it.next(), None);Modules§
Structs§
- ZbiContainer
- Main structure to work with ZBI format.
- ZbiContainer
Iterator - Container iterator
- ZbiFlags
- Flags associated with an item.
- ZbiItem
- ZbiItem is element representation in
ZbiContainer
Enums§
- ZbiError
- Error values that can be returned by function in this library
- ZbiType
- All possible
ZbiHeader.typevalues.
Constants§
- ZBI_
ALIGNMENT_ USIZE ZbiContainerrequires buffer and each entry to be aligned to this amount of bytes.align_buffercan be used to adjust buffer alignment to match this requirement.
Functions§
- align_
buffer - Aligns provided slice to
ZBI_ALIGNMENT_USIZEbytes. - merge_
within - Merges two ZBI containers stored on the same buffer.