Skip to main content

merge_within

Function merge_within 

Source
pub fn merge_within(
    buffer: &mut [u8],
    second_start: usize,
) -> Result<ZbiContainer<&mut [u8]>, ZbiError>
Expand description

Merges two ZBI containers stored on the same buffer.

A typical use scenario is when the caller wants to append ZBI items that need to borrow the existing container in order to be created, but wants to reuse the unused buffer for memory optimization. The caller can split out the unused buffer, borrow the existing container, creates a new container in the unused buffer, and then use this API to merge them together.

§Args:

  • buffer: The buffer that contains the two ZBI containers. The first container must start from the beginning.
  • second_start: The offset to the second container in the buffer. The offset must be aligned to ZBI_ALIGNMENT_USIZE.

§Returns

  • On success returns an instance of ZbiContainer representing the merged container.