restore method
Restores a handle from snapshot data.
Returns the new handle address as an int, or throws on error.
Implementation
@override
int restore(Uint8List data) {
final cData = calloc<Uint8>(data.length);
final outError = calloc<Pointer<Char>>();
try {
cData.asTypedList(data.length).setAll(0, data);
final handle = ffi_native.monty_restore(cData, data.length, outError);
if (handle == nullptr) {
final errorMsg = _readAndFreeString(outError.value);
throw MontyException(
message: errorMsg ?? 'monty_restore returned null',
);
}
return handle.address;
} finally {
calloc
..free(cData)
..free(outError);
}
}