jsonSchemaString property

String get jsonSchemaString

JSON Schema text consumed by the structured-output C ABI.

Delegates to rac_structured_output_schema_to_json_proto so every SDK shares the same byte-exact, key-sorted, compact serializer — mirroring Swift RAJSONSchema.jsonSchemaString.

Implementation

String get jsonSchemaString {
  final fn = RacNative.bindings.rac_structured_output_schema_to_json_proto;
  final bytes = writeToBuffer();
  final requestPtr = DartBridgeProtoUtils.copyBytes(bytes);
  final out = calloc<RacProtoBuffer>();
  try {
    RacNative.bindings.rac_proto_buffer_init(out);
    final code = fn(requestPtr, bytes.length, out);
    if (code != 0 || out.ref.status != 0) {
      throw SDKException.processingFailed(
        'rac_structured_output_schema_to_json_proto failed '
        '(code=$code status=${out.ref.status})',
      );
    }
    if (out.ref.data == ffi.nullptr || out.ref.size == 0) {
      throw SDKException.processingFailed(
        'rac_structured_output_schema_to_json_proto returned empty output',
      );
    }
    return String.fromCharCodes(out.ref.data.asTypedList(out.ref.size));
  } finally {
    RacNative.bindings.rac_proto_buffer_free(out);
    calloc.free(requestPtr);
    calloc.free(out);
  }
}