Function new_boxed

Source
pub fn new_boxed<T: MaybeDynSized<Metadata = usize> + ?Sized>(
    header: T::Header,
    additional_bytes_slices: &[&[u8]],
) -> Box<T>
Expand description

Creates a new tag implementing MaybeDynSized on the heap.

This works for sized and unsized tags. However, it only makes sense to use this for tags that are DSTs (unsized). For regular sized structs, you can just create a typical constructor and box the result.

The provided header’ total size (see Header) will be set dynamically by this function using Header::set_size. However, it must contain all other relevant metadata or update it in the set_size callback.

§Parameters

  • additional_bytes_slices: Array of byte slices that should be included without additional padding in-between. You don’t need to add the bytes for Header, but only additional payload.