evaluateBatch method
Implementation
BatchEvaluationResponse evaluateBatch(List<EvaluationRequest> requests) {
if (requests.isEmpty) {
throw ValidationError('requests must not be empty');
}
final requestsJson = jsonEncode(requests.map((r) => r.toJson()).toList());
final requestsUtf8 = requestsJson.toNativeUtf8();
final resultPtr =
_bindings.evaluate_batch(_engine, requestsUtf8.cast<Char>());
final result = _pointerToString(resultPtr);
_bindings.destroy_string(resultPtr);
calloc.free(requestsUtf8);
final response = Result<BatchEvaluationResponse>.fromJson(
jsonDecode(result) as Map<String, dynamic>,
(json) => BatchEvaluationResponse.fromJson(json as Map<String, dynamic>),
);
if (response.status != Status.success) {
throw EvaluationError(
'Failed to evaluate batch: ${response.errorMessage}');
}
return response.result!;
}