createFromProto static method
Create a solution handle from proto-encoded config bytes.
Implementation
static SolutionFfiResult createFromProto(Uint8List bytes) {
final bufferPtr = calloc<Uint8>(bytes.length);
final handlePtr = calloc<RacHandle>();
try {
bufferPtr.asTypedList(bytes.length).setAll(0, bytes);
final rc = NativeFunctions.solutionCreateFromProto(
bufferPtr.cast<Void>(),
bytes.length,
handlePtr,
);
if (rc != RAC_SUCCESS) {
return SolutionFfiResult(resultCode: rc);
}
return SolutionFfiResult(
resultCode: rc,
handle: SolutionNativeHandle._(handlePtr.value),
);
} finally {
calloc.free(bufferPtr);
calloc.free(handlePtr);
}
}