pub fn retrieve_custom_data<T: StableType + AsDynSizeBytes>(
    idx: usize
) -> Option<SBox<T>>
Expand description

Retrieves a pointer to some SBox stored previously.

See also store_custom_data.

This function is intended to be invoked inside the #[post_upgrade] canister method. Right after stable_memory_post_upgrade() invocation. After retrieval, the key gets “forgotten”, allowing reusing it again for other data.

Any panic in the #[post_upgrade] canister method results in broken canister. Please, be careful.

Internally calls StableMemoryAllocator::retrieve_custom_data.

Examples

See examples of store_custom_data.

Panics

Panics if there is no initialized stable memory allocator.