sodiumScope<R> function
Runs body in a fresh SodiumScope, disposing everything the scope still
owns, in reverse (LIFO) order, when body returns or throws.
This is synchronous by design: the operations that use it never allocate
across an await, so there is no Future branch. The value produced by
body is returned unchanged.
Implementation
R sodiumScope<R>(LibSodiumFFI sodium, R Function(SodiumScope scope) body) {
final scope = SodiumScope._(sodium);
try {
return body(scope);
} finally {
scope._releaseAll();
}
}