Skip to main content

with_kdf_memory_permit

Function with_kdf_memory_permit 

Source
pub fn with_kdf_memory_permit<T>(cost_kib: u32, f: impl FnOnce() -> T) -> T
Expand description

Runs f (a key derivation) while holding a reservation of cost_kib against the global memory budget, blocking until enough budget is free.

A cost larger than the whole budget is clamped to it, so an oversized (but validated) derivation waits for exclusive use of the budget and then runs alone rather than deadlocking.