Skip to main content

cast_native_slice

Function cast_native_slice 

Source
pub fn cast_native_slice<T: Pod>(bytes: &[u8]) -> Result<&[T], PodCastError>
Expand description

Helper function to safely cast native types in mixed structures.

When you have a portion of your structure that contains only native types (no I24), you can use this function to safely cast that portion using bytemuck.

§Arguments

  • bytes - Byte slice containing the native types.

§Returns

A slice of the target type, or an error if the cast fails.