engineRunJson static method

String? engineRunJson(
  1. SyniEngineNative engine,
  2. SyniPreset preset,
  3. int seed,
  4. String requestJson,
)

Runs a synchronous inference. Returns the JSON response as a Dart string, or null on failure. The native string buffer is freed internally — callers do not need to call stringFree.

Implementation

static String? engineRunJson(
  SyniEngineNative engine,
  SyniPreset preset,
  int seed,
  String requestJson,
) {
  initialize();
  final jsonPtr = requestJson.toNativeUtf8();
  try {
    final resultPtr = _engineRunJson!(engine, preset.value, seed, jsonPtr);
    if (resultPtr == nullptr) return null;
    final result = resultPtr.cast<Utf8>().toDartString();
    _stringFree!(resultPtr);
    return result;
  } finally {
    malloc.free(jsonPtr);
  }
}