fn with_nvs<R>(
f: impl FnOnce(&mut Nvs<FlashStorage<'static>>) -> R,
) -> Option<R>Expand description
Run f against the global handle if storage is up and the flash is idle.
Synchronous by contract: f must not await, otherwise the busy flag
would stay set for the whole suspension. The operation runs inside a
critical section to scope the RefCell borrow (critical_section::Mutex
loans cannot escape the closure). Interrupt masking over the long flash
calls happens anyway: esp-storage takes its own interrupt lock around
every ROM spiflash call (verified via cargo tree — feature
critical-section is on); the outer section only additionally covers the
bookkeeping gaps between calls. Whether a save disturbs a live AP link
long enough to matter is a hardware check (see TODO.md).