pub fn guarded<T>(
stage: &'static str,
step: impl FnOnce() -> Result<T, MediaError>,
) -> Result<T, MediaError>Expand description
Run any fallible step of the still pipeline behind the same unwind boundary.
Public because its one caller, the derivative pipeline in capsule-library’s lifecycle, is
in another crate; the catch_unwind itself stays here, the one module the stateless core
sanctions it in.
Not just for decode — that is not the only third-party code the import path runs over pixels:
the placeholder goes through chromahash (also pre-1.0) and the derivative through the
encoder, and the module’s promise is that none of them can abort an import — not that the
decoder specifically cannot. stage names the step in the warning so a caught panic is
attributable.
AssertUnwindSafe is sound for the callers here: each closure borrows shared slices and
stateless values, so a caught unwind cannot leave a Capsule-owned invariant torn.