read_fixed_for_reference

Function read_fixed_for_reference 

Source
pub unsafe fn read_fixed_for_reference<T: AsFixedSizeBytes + StableType>(
    ptr: StablePtr,
) -> T
Expand description

Reads a StableType value that won’t move implementing AsFixedSizeBytes trait from stable memory.

See also read_fixed_for_move.

This function creates an intermediate buffer of AsFixedSizeBytes::SIZE bytes, reads bytes from stable memory into it, then deserializes this buffer into a value itself and then sets its stable drop flag to off position.

§Safety

Make sure you’re reading from a valid memory block. All kinds of bad things can happen. This function manages stable memory ownership, this value won’t be stable-dropped after it goes out of scope. Make sure you treat it accordingly.