labStart method

String? labStart(
  1. String protocolJson,
  2. int startedAtMs
)

Start a lab session. Returns null on success, or a short error string identifying the failure code from the runtime.

The runtime FFI returns c_int: 0 on success, 1 on "Lab session already active", and other small integers for other validation failures. We surface non-zero codes as "lab_start: error code N" so callers (e.g. Mirror's MirrorLabSessionManager) can distinguish success from failure without having to interpret the raw integer.

Implementation

String? labStart(String protocolJson, int startedAtMs) {
  return _withCString(protocolJson, (p) {
    final rc = _ffi.labStart(_handle, p, startedAtMs);
    if (rc == 0) return null;
    _noteFailure();
    return 'lab_start: error code $rc';
  });
}