executeSync<S, E extends Object, WireSyncType> method
- SyncTask<
S, E, WireSyncType> task
Similar to executeNormal, except that this will return synchronously
Implementation
S executeSync<S, E extends Object, WireSyncType>(
SyncTask<S, E, WireSyncType> task) {
final WireSyncType syncReturn;
try {
syncReturn = task.callFfi();
} catch (e, s) {
if (e is FrbException) rethrow;
// When in Web, because Rust only support `abort` (and not `unwind`)
// we will get `JSObject0:<RuntimeError: unreachable>`.
// Here we translate the exception.
throw PanicException('EXECUTE_SYNC_ABORT $e $s');
}
try {
return task.codec.decodeWireSyncType(syncReturn);
} finally {
task.codec.freeWireSyncRust2Dart(
syncReturn, task.apiImpl.generalizedFrbRustBinding);
}
}