deserializeEncryptionSession method

SealdEncryptionSession deserializeEncryptionSession(
  1. String serializedSession
)

Deserialize a serialized session. For advanced use.

serializedSession - The serialized encryption session to deserialize. Returns the deserialized SealdEncryptionSession instance.

Implementation

SealdEncryptionSession deserializeEncryptionSession(
    String serializedSession) {
  if (_closed) {
    throw SealdException(
        code: "INSTANCE_CLOSED",
        id: "FLUTTER_INSTANCE_CLOSED",
        description: "Instance already closed.");
  }
  final Pointer<Utf8> nativeSerializedSession =
      serializedSession.toNativeUtf8();
  final Pointer<Pointer<NativeSealdEncryptionSession>> nativeResult =
      calloc<Pointer<NativeSealdEncryptionSession>>();
  final Pointer<Pointer<NativeSealdError>> err =
      calloc<Pointer<NativeSealdError>>();

  final int resultCode = _bindings.SealdSdk_DeserializeEncryptionSession(
      _ptr.pointer(), nativeSerializedSession, nativeResult, err);

  calloc.free(nativeSerializedSession);

  if (resultCode != 0) {
    calloc.free(nativeResult);
    throw SealdException._fromCPtr(err);
  } else {
    SealdEncryptionSession result =
        SealdEncryptionSession._fromC(nativeResult.value);
    calloc.free(nativeResult);
    calloc.free(err);
    return result;
  }
}