osom_lib_arrays/const_helpers/
endianness_helpers.rs1use osom_lib_macros::debug_check_or_release_hint;
2
3#[allow(private_bounds)]
14#[inline(always)]
15#[must_use]
16pub const unsafe fn from_le_const_u64(slice: &[u8], start: usize) -> u64 {
17 debug_check_or_release_hint!(slice.len() >= start + size_of::<u64>());
18 let array_ptr = unsafe { slice.as_ptr().add(start) }.cast::<[u8; size_of::<u64>()]>();
19 u64::from_le_bytes(unsafe { *array_ptr })
20}
21
22#[allow(private_bounds)]
33#[inline(always)]
34#[must_use]
35pub const unsafe fn from_be_const_u32(slice: &[u8], start: usize) -> u32 {
36 debug_check_or_release_hint!(slice.len() >= start + size_of::<u32>());
37 let array_ptr = unsafe { slice.as_ptr().add(start) }.cast::<[u8; size_of::<u32>()]>();
38 u32::from_be_bytes(unsafe { *array_ptr })
39}