// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.12.0.

// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field

import 'api.dart';
import 'dart:async';
import 'dart:convert';
import 'frb_generated.dart';
import 'frb_generated.io.dart'
    if (dart.library.js_interop) 'frb_generated.web.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

/// Main entrypoint of the Rust API
class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
  @internal
  static final instance = RustLib._();

  RustLib._();

  /// Initialize flutter_rust_bridge
  static Future<void> init({
    RustLibApi? api,
    BaseHandler? handler,
    ExternalLibrary? externalLibrary,
    bool forceSameCodegenVersion = true,
  }) async {
    await instance.initImpl(
      api: api,
      handler: handler,
      externalLibrary: externalLibrary,
      forceSameCodegenVersion: forceSameCodegenVersion,
    );
  }

  /// Initialize flutter_rust_bridge in mock mode.
  /// No libraries for FFI are loaded.
  static void initMock({
    required RustLibApi api,
  }) {
    instance.initMockImpl(
      api: api,
    );
  }

  /// Dispose flutter_rust_bridge
  ///
  /// The call to this function is optional, since flutter_rust_bridge (and everything else)
  /// is automatically disposed when the app stops.
  static void dispose() => instance.disposeImpl();

  @override
  ApiImplConstructor<RustLibApiImpl, RustLibWire> get apiImplConstructor =>
      RustLibApiImpl.new;

  @override
  WireConstructor<RustLibWire> get wireConstructor =>
      RustLibWire.fromExternalLibrary;

  @override
  Future<void> executeRustInitializers() async {}

  @override
  ExternalLibraryLoaderConfig get defaultExternalLibraryLoaderConfig =>
      kDefaultExternalLibraryLoaderConfig;

  @override
  String get codegenVersion => '2.12.0';

  @override
  int get rustContentHash => 2145259673;

  static const kDefaultExternalLibraryLoaderConfig =
      ExternalLibraryLoaderConfig(
    stem: 'kusoft_dart',
    ioDirectory: 'rust/target/release/',
    webPrefix: 'pkg/',
    wasmBindgenName: 'wasm_bindgen',
  );
}

abstract class RustLibApi extends BaseApi {
  void crateApiCallSignalingClose({required CallSignaling that});

  bool crateApiCallSignalingIsConnected({required CallSignaling that});

  Stream<String> crateApiCallSignalingNotifications(
      {required CallSignaling that});

  Future<String> crateApiCallSignalingSendCommand(
      {required CallSignaling that,
      required String command,
      required String extraJson});

  Future<HandshakeInfo> crateApiKusoftSessionConnect(
      {required KusoftSession that});

  void crateApiKusoftSessionDisconnect({required KusoftSession that});

  KusoftSession crateApiKusoftSessionNew(
      {required SessionOptions options, RustStreamSink<WireLogEvent>? wireLog});

  bool crateApiKusoftSessionPingInteractive({required KusoftSession that});

  Stream<PushEvent> crateApiKusoftSessionPushes({required KusoftSession that});

  Future<Uint8List> crateApiKusoftSessionRequest(
      {required KusoftSession that,
      required int opcode,
      required List<int> payload});

  Future<RequestOutcome> crateApiKusoftSessionRequestFull(
      {required KusoftSession that,
      required int opcode,
      required String jsonIn});

  Future<String> crateApiKusoftSessionRequestJson(
      {required KusoftSession that,
      required int opcode,
      required String jsonIn});

  int crateApiKusoftSessionSend(
      {required KusoftSession that,
      required int opcode,
      required List<int> payload});

  void crateApiKusoftSessionSetPingInteractive(
      {required KusoftSession that, required bool interactive});

  String crateApiKusoftSessionState({required KusoftSession that});

  Stream<UploadEvent> crateApiKusoftSessionUploadFile(
      {required KusoftSession that,
      required String url,
      required List<int> data,
      required String filename,
      String? userAgent});

  Stream<UploadEvent> crateApiKusoftSessionUploadFilePath(
      {required KusoftSession that,
      required String url,
      required String path,
      required String filename,
      String? contentType,
      String? connection,
      String? userAgent});

  Stream<UploadEvent> crateApiKusoftSessionUploadPhoto(
      {required KusoftSession that,
      required String url,
      required List<int> data,
      required String filename,
      String? userAgent});

  Stream<UploadEvent> crateApiKusoftSessionUploadPhotoPath(
      {required KusoftSession that,
      required String url,
      required String path,
      required String filename,
      String? userAgent});

  Stream<UploadEvent> crateApiKusoftSessionUploadVideoPath(
      {required KusoftSession that,
      required String url,
      required String path,
      required int chunkSize,
      required int concurrency});

  String crateApiKusoftSessionUserAgent({required KusoftSession that});

  Uint8List crateApiAuthMode(
      {required List<int> signature,
      required List<int> dex,
      required List<int> so,
      required PlatformInt64 callsSeed,
      required String deviceId});

  Future<CallSignaling> crateApiConnectCallSignaling(
      {required String url, String? userAgent, String? proxy});

  CallParams? crateApiDecodeVcp(
      {required String vcp, required String conversationId});

  void crateApiSetTrustMincifryCa({required bool enabled});

  bool crateApiTrustMincifryCa();

  RustArcIncrementStrongCountFnType
      get rust_arc_increment_strong_count_CallSignaling;

  RustArcDecrementStrongCountFnType
      get rust_arc_decrement_strong_count_CallSignaling;

  CrossPlatformFinalizerArg
      get rust_arc_decrement_strong_count_CallSignalingPtr;

  RustArcIncrementStrongCountFnType
      get rust_arc_increment_strong_count_KusoftSession;

  RustArcDecrementStrongCountFnType
      get rust_arc_decrement_strong_count_KusoftSession;

  CrossPlatformFinalizerArg
      get rust_arc_decrement_strong_count_KusoftSessionPtr;
}

class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
  RustLibApiImpl({
    required super.handler,
    required super.wire,
    required super.generalizedFrbRustBinding,
    required super.portManager,
  });

  @override
  void crateApiCallSignalingClose({required CallSignaling that}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
            that, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 1)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiCallSignalingCloseConstMeta,
      argValues: [that],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiCallSignalingCloseConstMeta => const TaskConstMeta(
        debugName: "CallSignaling_close",
        argNames: ["that"],
      );

  @override
  bool crateApiCallSignalingIsConnected({required CallSignaling that}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
            that, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 2)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_bool,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiCallSignalingIsConnectedConstMeta,
      argValues: [that],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiCallSignalingIsConnectedConstMeta =>
      const TaskConstMeta(
        debugName: "CallSignaling_is_connected",
        argNames: ["that"],
      );

  @override
  Stream<String> crateApiCallSignalingNotifications(
      {required CallSignaling that}) {
    final sink = RustStreamSink<String>();
    unawaited(handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
            that, serializer);
        sse_encode_StreamSink_String_Sse(sink, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 3, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiCallSignalingNotificationsConstMeta,
      argValues: [that, sink],
      apiImpl: this,
    )));
    return sink.stream;
  }

  TaskConstMeta get kCrateApiCallSignalingNotificationsConstMeta =>
      const TaskConstMeta(
        debugName: "CallSignaling_notifications",
        argNames: ["that", "sink"],
      );

  @override
  Future<String> crateApiCallSignalingSendCommand(
      {required CallSignaling that,
      required String command,
      required String extraJson}) {
    return handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
            that, serializer);
        sse_encode_String(command, serializer);
        sse_encode_String(extraJson, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 4, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_String,
        decodeErrorData: sse_decode_String,
      ),
      constMeta: kCrateApiCallSignalingSendCommandConstMeta,
      argValues: [that, command, extraJson],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiCallSignalingSendCommandConstMeta =>
      const TaskConstMeta(
        debugName: "CallSignaling_send_command",
        argNames: ["that", "command", "extraJson"],
      );

  @override
  Future<HandshakeInfo> crateApiKusoftSessionConnect(
      {required KusoftSession that}) {
    return handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 5, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_handshake_info,
        decodeErrorData: sse_decode_String,
      ),
      constMeta: kCrateApiKusoftSessionConnectConstMeta,
      argValues: [that],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionConnectConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_connect",
        argNames: ["that"],
      );

  @override
  void crateApiKusoftSessionDisconnect({required KusoftSession that}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 6)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionDisconnectConstMeta,
      argValues: [that],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionDisconnectConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_disconnect",
        argNames: ["that"],
      );

  @override
  KusoftSession crateApiKusoftSessionNew(
      {required SessionOptions options,
      RustStreamSink<WireLogEvent>? wireLog}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_box_autoadd_session_options(options, serializer);
        sse_encode_opt_StreamSink_wire_log_event_Sse(wireLog, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 7)!;
      },
      codec: SseCodec(
        decodeSuccessData:
            sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession,
        decodeErrorData: sse_decode_String,
      ),
      constMeta: kCrateApiKusoftSessionNewConstMeta,
      argValues: [options, wireLog],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionNewConstMeta => const TaskConstMeta(
        debugName: "KusoftSession_new",
        argNames: ["options", "wireLog"],
      );

  @override
  bool crateApiKusoftSessionPingInteractive({required KusoftSession that}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 8)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_bool,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionPingInteractiveConstMeta,
      argValues: [that],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionPingInteractiveConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_ping_interactive",
        argNames: ["that"],
      );

  @override
  Stream<PushEvent> crateApiKusoftSessionPushes({required KusoftSession that}) {
    final sink = RustStreamSink<PushEvent>();
    unawaited(handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_StreamSink_push_event_Sse(sink, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 9, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionPushesConstMeta,
      argValues: [that, sink],
      apiImpl: this,
    )));
    return sink.stream;
  }

  TaskConstMeta get kCrateApiKusoftSessionPushesConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_pushes",
        argNames: ["that", "sink"],
      );

  @override
  Future<Uint8List> crateApiKusoftSessionRequest(
      {required KusoftSession that,
      required int opcode,
      required List<int> payload}) {
    return handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_u_16(opcode, serializer);
        sse_encode_list_prim_u_8_loose(payload, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 10, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_list_prim_u_8_strict,
        decodeErrorData: sse_decode_String,
      ),
      constMeta: kCrateApiKusoftSessionRequestConstMeta,
      argValues: [that, opcode, payload],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionRequestConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_request",
        argNames: ["that", "opcode", "payload"],
      );

  @override
  Future<RequestOutcome> crateApiKusoftSessionRequestFull(
      {required KusoftSession that,
      required int opcode,
      required String jsonIn}) {
    return handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_u_16(opcode, serializer);
        sse_encode_String(jsonIn, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 11, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_request_outcome,
        decodeErrorData: sse_decode_String,
      ),
      constMeta: kCrateApiKusoftSessionRequestFullConstMeta,
      argValues: [that, opcode, jsonIn],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionRequestFullConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_request_full",
        argNames: ["that", "opcode", "jsonIn"],
      );

  @override
  Future<String> crateApiKusoftSessionRequestJson(
      {required KusoftSession that,
      required int opcode,
      required String jsonIn}) {
    return handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_u_16(opcode, serializer);
        sse_encode_String(jsonIn, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 12, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_String,
        decodeErrorData: sse_decode_String,
      ),
      constMeta: kCrateApiKusoftSessionRequestJsonConstMeta,
      argValues: [that, opcode, jsonIn],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionRequestJsonConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_request_json",
        argNames: ["that", "opcode", "jsonIn"],
      );

  @override
  int crateApiKusoftSessionSend(
      {required KusoftSession that,
      required int opcode,
      required List<int> payload}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_u_16(opcode, serializer);
        sse_encode_list_prim_u_8_loose(payload, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 13)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_u_32,
        decodeErrorData: sse_decode_String,
      ),
      constMeta: kCrateApiKusoftSessionSendConstMeta,
      argValues: [that, opcode, payload],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionSendConstMeta => const TaskConstMeta(
        debugName: "KusoftSession_send",
        argNames: ["that", "opcode", "payload"],
      );

  @override
  void crateApiKusoftSessionSetPingInteractive(
      {required KusoftSession that, required bool interactive}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_bool(interactive, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 14)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionSetPingInteractiveConstMeta,
      argValues: [that, interactive],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionSetPingInteractiveConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_set_ping_interactive",
        argNames: ["that", "interactive"],
      );

  @override
  String crateApiKusoftSessionState({required KusoftSession that}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 15)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_String,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionStateConstMeta,
      argValues: [that],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionStateConstMeta => const TaskConstMeta(
        debugName: "KusoftSession_state",
        argNames: ["that"],
      );

  @override
  Stream<UploadEvent> crateApiKusoftSessionUploadFile(
      {required KusoftSession that,
      required String url,
      required List<int> data,
      required String filename,
      String? userAgent}) {
    final sink = RustStreamSink<UploadEvent>();
    unawaited(handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_String(url, serializer);
        sse_encode_list_prim_u_8_loose(data, serializer);
        sse_encode_String(filename, serializer);
        sse_encode_opt_String(userAgent, serializer);
        sse_encode_StreamSink_upload_event_Sse(sink, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 16, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionUploadFileConstMeta,
      argValues: [that, url, data, filename, userAgent, sink],
      apiImpl: this,
    )));
    return sink.stream;
  }

  TaskConstMeta get kCrateApiKusoftSessionUploadFileConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_upload_file",
        argNames: ["that", "url", "data", "filename", "userAgent", "sink"],
      );

  @override
  Stream<UploadEvent> crateApiKusoftSessionUploadFilePath(
      {required KusoftSession that,
      required String url,
      required String path,
      required String filename,
      String? contentType,
      String? connection,
      String? userAgent}) {
    final sink = RustStreamSink<UploadEvent>();
    unawaited(handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_String(url, serializer);
        sse_encode_String(path, serializer);
        sse_encode_String(filename, serializer);
        sse_encode_opt_String(contentType, serializer);
        sse_encode_opt_String(connection, serializer);
        sse_encode_opt_String(userAgent, serializer);
        sse_encode_StreamSink_upload_event_Sse(sink, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 17, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionUploadFilePathConstMeta,
      argValues: [
        that,
        url,
        path,
        filename,
        contentType,
        connection,
        userAgent,
        sink
      ],
      apiImpl: this,
    )));
    return sink.stream;
  }

  TaskConstMeta get kCrateApiKusoftSessionUploadFilePathConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_upload_file_path",
        argNames: [
          "that",
          "url",
          "path",
          "filename",
          "contentType",
          "connection",
          "userAgent",
          "sink"
        ],
      );

  @override
  Stream<UploadEvent> crateApiKusoftSessionUploadPhoto(
      {required KusoftSession that,
      required String url,
      required List<int> data,
      required String filename,
      String? userAgent}) {
    final sink = RustStreamSink<UploadEvent>();
    unawaited(handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_String(url, serializer);
        sse_encode_list_prim_u_8_loose(data, serializer);
        sse_encode_String(filename, serializer);
        sse_encode_opt_String(userAgent, serializer);
        sse_encode_StreamSink_upload_event_Sse(sink, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 18, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionUploadPhotoConstMeta,
      argValues: [that, url, data, filename, userAgent, sink],
      apiImpl: this,
    )));
    return sink.stream;
  }

  TaskConstMeta get kCrateApiKusoftSessionUploadPhotoConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_upload_photo",
        argNames: ["that", "url", "data", "filename", "userAgent", "sink"],
      );

  @override
  Stream<UploadEvent> crateApiKusoftSessionUploadPhotoPath(
      {required KusoftSession that,
      required String url,
      required String path,
      required String filename,
      String? userAgent}) {
    final sink = RustStreamSink<UploadEvent>();
    unawaited(handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_String(url, serializer);
        sse_encode_String(path, serializer);
        sse_encode_String(filename, serializer);
        sse_encode_opt_String(userAgent, serializer);
        sse_encode_StreamSink_upload_event_Sse(sink, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 19, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionUploadPhotoPathConstMeta,
      argValues: [that, url, path, filename, userAgent, sink],
      apiImpl: this,
    )));
    return sink.stream;
  }

  TaskConstMeta get kCrateApiKusoftSessionUploadPhotoPathConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_upload_photo_path",
        argNames: ["that", "url", "path", "filename", "userAgent", "sink"],
      );

  @override
  Stream<UploadEvent> crateApiKusoftSessionUploadVideoPath(
      {required KusoftSession that,
      required String url,
      required String path,
      required int chunkSize,
      required int concurrency}) {
    final sink = RustStreamSink<UploadEvent>();
    unawaited(handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        sse_encode_String(url, serializer);
        sse_encode_String(path, serializer);
        sse_encode_u_32(chunkSize, serializer);
        sse_encode_u_32(concurrency, serializer);
        sse_encode_StreamSink_upload_event_Sse(sink, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 20, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionUploadVideoPathConstMeta,
      argValues: [that, url, path, chunkSize, concurrency, sink],
      apiImpl: this,
    )));
    return sink.stream;
  }

  TaskConstMeta get kCrateApiKusoftSessionUploadVideoPathConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_upload_video_path",
        argNames: ["that", "url", "path", "chunkSize", "concurrency", "sink"],
      );

  @override
  String crateApiKusoftSessionUserAgent({required KusoftSession that}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
            that, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 21)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_String,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiKusoftSessionUserAgentConstMeta,
      argValues: [that],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiKusoftSessionUserAgentConstMeta =>
      const TaskConstMeta(
        debugName: "KusoftSession_user_agent",
        argNames: ["that"],
      );

  @override
  Uint8List crateApiAuthMode(
      {required List<int> signature,
      required List<int> dex,
      required List<int> so,
      required PlatformInt64 callsSeed,
      required String deviceId}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_list_prim_u_8_loose(signature, serializer);
        sse_encode_list_prim_u_8_loose(dex, serializer);
        sse_encode_list_prim_u_8_loose(so, serializer);
        sse_encode_i_64(callsSeed, serializer);
        sse_encode_String(deviceId, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 22)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_list_prim_u_8_strict,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiAuthModeConstMeta,
      argValues: [signature, dex, so, callsSeed, deviceId],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiAuthModeConstMeta => const TaskConstMeta(
        debugName: "auth_mode",
        argNames: ["signature", "dex", "so", "callsSeed", "deviceId"],
      );

  @override
  Future<CallSignaling> crateApiConnectCallSignaling(
      {required String url, String? userAgent, String? proxy}) {
    return handler.executeNormal(NormalTask(
      callFfi: (port_) {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_String(url, serializer);
        sse_encode_opt_String(userAgent, serializer);
        sse_encode_opt_String(proxy, serializer);
        pdeCallFfi(generalizedFrbRustBinding, serializer,
            funcId: 23, port: port_);
      },
      codec: SseCodec(
        decodeSuccessData:
            sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling,
        decodeErrorData: sse_decode_String,
      ),
      constMeta: kCrateApiConnectCallSignalingConstMeta,
      argValues: [url, userAgent, proxy],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiConnectCallSignalingConstMeta =>
      const TaskConstMeta(
        debugName: "connect_call_signaling",
        argNames: ["url", "userAgent", "proxy"],
      );

  @override
  CallParams? crateApiDecodeVcp(
      {required String vcp, required String conversationId}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_String(vcp, serializer);
        sse_encode_String(conversationId, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 24)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_opt_box_autoadd_call_params,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiDecodeVcpConstMeta,
      argValues: [vcp, conversationId],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiDecodeVcpConstMeta => const TaskConstMeta(
        debugName: "decode_vcp",
        argNames: ["vcp", "conversationId"],
      );

  @override
  void crateApiSetTrustMincifryCa({required bool enabled}) {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        sse_encode_bool(enabled, serializer);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 25)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_unit,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiSetTrustMincifryCaConstMeta,
      argValues: [enabled],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiSetTrustMincifryCaConstMeta => const TaskConstMeta(
        debugName: "set_trust_mincifry_ca",
        argNames: ["enabled"],
      );

  @override
  bool crateApiTrustMincifryCa() {
    return handler.executeSync(SyncTask(
      callFfi: () {
        final serializer = SseSerializer(generalizedFrbRustBinding);
        return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 26)!;
      },
      codec: SseCodec(
        decodeSuccessData: sse_decode_bool,
        decodeErrorData: null,
      ),
      constMeta: kCrateApiTrustMincifryCaConstMeta,
      argValues: [],
      apiImpl: this,
    ));
  }

  TaskConstMeta get kCrateApiTrustMincifryCaConstMeta => const TaskConstMeta(
        debugName: "trust_mincifry_ca",
        argNames: [],
      );

  RustArcIncrementStrongCountFnType
      get rust_arc_increment_strong_count_CallSignaling => wire
          .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling;

  RustArcDecrementStrongCountFnType
      get rust_arc_decrement_strong_count_CallSignaling => wire
          .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling;

  RustArcIncrementStrongCountFnType
      get rust_arc_increment_strong_count_KusoftSession => wire
          .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession;

  RustArcDecrementStrongCountFnType
      get rust_arc_decrement_strong_count_KusoftSession => wire
          .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession;

  @protected
  AnyhowException dco_decode_AnyhowException(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return AnyhowException(raw as String);
  }

  @protected
  CallSignaling
      dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return CallSignalingImpl.frbInternalDcoDecode(raw as List<dynamic>);
  }

  @protected
  KusoftSession
      dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return KusoftSessionImpl.frbInternalDcoDecode(raw as List<dynamic>);
  }

  @protected
  CallSignaling
      dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return CallSignalingImpl.frbInternalDcoDecode(raw as List<dynamic>);
  }

  @protected
  KusoftSession
      dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return KusoftSessionImpl.frbInternalDcoDecode(raw as List<dynamic>);
  }

  @protected
  CallSignaling
      dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return CallSignalingImpl.frbInternalDcoDecode(raw as List<dynamic>);
  }

  @protected
  KusoftSession
      dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return KusoftSessionImpl.frbInternalDcoDecode(raw as List<dynamic>);
  }

  @protected
  RustStreamSink<String> dco_decode_StreamSink_String_Sse(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    throw UnimplementedError();
  }

  @protected
  RustStreamSink<PushEvent> dco_decode_StreamSink_push_event_Sse(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    throw UnimplementedError();
  }

  @protected
  RustStreamSink<UploadEvent> dco_decode_StreamSink_upload_event_Sse(
      dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    throw UnimplementedError();
  }

  @protected
  RustStreamSink<WireLogEvent> dco_decode_StreamSink_wire_log_event_Sse(
      dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    throw UnimplementedError();
  }

  @protected
  String dco_decode_String(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw as String;
  }

  @protected
  bool dco_decode_bool(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw as bool;
  }

  @protected
  bool dco_decode_box_autoadd_bool(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw as bool;
  }

  @protected
  CallParams dco_decode_box_autoadd_call_params(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return dco_decode_call_params(raw);
  }

  @protected
  PlatformInt64 dco_decode_box_autoadd_i_64(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return dco_decode_i_64(raw);
  }

  @protected
  SessionOptions dco_decode_box_autoadd_session_options(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return dco_decode_session_options(raw);
  }

  @protected
  CallParams dco_decode_call_params(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    final arr = raw as List<dynamic>;
    if (arr.length != 7)
      throw Exception('unexpected arr length: expect 7 but see ${arr.length}');
    return CallParams(
      token: dco_decode_String(arr[0]),
      wsEndpoint: dco_decode_String(arr[1]),
      stun: dco_decode_opt_String(arr[2]),
      turn: dco_decode_list_String(arr[3]),
      turnUser: dco_decode_opt_String(arr[4]),
      turnPassword: dco_decode_opt_String(arr[5]),
      isVideo: dco_decode_bool(arr[6]),
    );
  }

  @protected
  HandshakeInfo dco_decode_handshake_info(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    final arr = raw as List<dynamic>;
    if (arr.length != 4)
      throw Exception('unexpected arr length: expect 4 but see ${arr.length}');
    return HandshakeInfo(
      callsSeed: dco_decode_opt_box_autoadd_i_64(arr[0]),
      deviceName: dco_decode_opt_String(arr[1]),
      payload: dco_decode_list_prim_u_8_strict(arr[2]),
      payloadJson: dco_decode_String(arr[3]),
    );
  }

  @protected
  PlatformInt64 dco_decode_i_64(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return dcoDecodeI64(raw);
  }

  @protected
  List<String> dco_decode_list_String(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return (raw as List<dynamic>).map(dco_decode_String).toList();
  }

  @protected
  List<int> dco_decode_list_prim_u_8_loose(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw as List<int>;
  }

  @protected
  Uint8List dco_decode_list_prim_u_8_strict(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw as Uint8List;
  }

  @protected
  RustStreamSink<WireLogEvent>? dco_decode_opt_StreamSink_wire_log_event_Sse(
      dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw == null ? null : dco_decode_StreamSink_wire_log_event_Sse(raw);
  }

  @protected
  String? dco_decode_opt_String(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw == null ? null : dco_decode_String(raw);
  }

  @protected
  bool? dco_decode_opt_box_autoadd_bool(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw == null ? null : dco_decode_box_autoadd_bool(raw);
  }

  @protected
  CallParams? dco_decode_opt_box_autoadd_call_params(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw == null ? null : dco_decode_box_autoadd_call_params(raw);
  }

  @protected
  PlatformInt64? dco_decode_opt_box_autoadd_i_64(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw == null ? null : dco_decode_box_autoadd_i_64(raw);
  }

  @protected
  PushEvent dco_decode_push_event(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    final arr = raw as List<dynamic>;
    if (arr.length != 3)
      throw Exception('unexpected arr length: expect 3 but see ${arr.length}');
    return PushEvent(
      opcode: dco_decode_u_16(arr[0]),
      payload: dco_decode_list_prim_u_8_strict(arr[1]),
      payloadJson: dco_decode_String(arr[2]),
    );
  }

  @protected
  RequestOutcome dco_decode_request_outcome(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    final arr = raw as List<dynamic>;
    if (arr.length != 5)
      throw Exception('unexpected arr length: expect 5 but see ${arr.length}');
    return RequestOutcome(
      cmd: dco_decode_u_8(arr[0]),
      opcode: dco_decode_u_16(arr[1]),
      payloadJson: dco_decode_String(arr[2]),
      errorMessage: dco_decode_opt_String(arr[3]),
      errorKey: dco_decode_opt_String(arr[4]),
    );
  }

  @protected
  SessionOptions dco_decode_session_options(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    final arr = raw as List<dynamic>;
    if (arr.length != 23)
      throw Exception('unexpected arr length: expect 23 but see ${arr.length}');
    return SessionOptions(
      host: dco_decode_String(arr[0]),
      port: dco_decode_u_16(arr[1]),
      deviceId: dco_decode_String(arr[2]),
      instanceId: dco_decode_String(arr[3]),
      appVersion: dco_decode_String(arr[4]),
      buildNumber: dco_decode_i_64(arr[5]),
      deviceType: dco_decode_String(arr[6]),
      osVersion: dco_decode_String(arr[7]),
      timezone: dco_decode_String(arr[8]),
      screen: dco_decode_String(arr[9]),
      pushDeviceType: dco_decode_String(arr[10]),
      arch: dco_decode_String(arr[11]),
      locale: dco_decode_String(arr[12]),
      deviceName: dco_decode_String(arr[13]),
      deviceLocale: dco_decode_String(arr[14]),
      clientSessionId: dco_decode_i_64(arr[15]),
      pingIntervalSecs: dco_decode_u_64(arr[16]),
      pingInteractive: dco_decode_bool(arr[17]),
      autoReconnect: dco_decode_bool(arr[18]),
      insecureTls: dco_decode_bool(arr[19]),
      proxy: dco_decode_opt_String(arr[20]),
      isPwa: dco_decode_opt_box_autoadd_bool(arr[21]),
      headerUserAgent: dco_decode_opt_String(arr[22]),
    );
  }

  @protected
  int dco_decode_u_16(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw as int;
  }

  @protected
  int dco_decode_u_32(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw as int;
  }

  @protected
  BigInt dco_decode_u_64(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return dcoDecodeU64(raw);
  }

  @protected
  int dco_decode_u_8(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return raw as int;
  }

  @protected
  void dco_decode_unit(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return;
  }

  @protected
  UploadEvent dco_decode_upload_event(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    switch (raw[0]) {
      case 0:
        return UploadEvent_Progress(
          sent: dco_decode_u_64(raw[1]),
          total: dco_decode_u_64(raw[2]),
        );
      case 1:
        return UploadEvent_Done(
          status: dco_decode_u_16(raw[1]),
          body: dco_decode_list_prim_u_8_strict(raw[2]),
        );
      case 2:
        return UploadEvent_Error(
          message: dco_decode_String(raw[1]),
        );
      default:
        throw Exception("unreachable");
    }
  }

  @protected
  BigInt dco_decode_usize(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    return dcoDecodeU64(raw);
  }

  @protected
  WireLogEvent dco_decode_wire_log_event(dynamic raw) {
    // Codec=Dco (DartCObject based), see doc to use other codecs
    final arr = raw as List<dynamic>;
    if (arr.length != 5)
      throw Exception('unexpected arr length: expect 5 but see ${arr.length}');
    return WireLogEvent(
      direction: dco_decode_String(arr[0]),
      cmd: dco_decode_String(arr[1]),
      opcode: dco_decode_u_16(arr[2]),
      seq: dco_decode_u_16(arr[3]),
      json: dco_decode_String(arr[4]),
    );
  }

  @protected
  AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var inner = sse_decode_String(deserializer);
    return AnyhowException(inner);
  }

  @protected
  CallSignaling
      sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return CallSignalingImpl.frbInternalSseDecode(
        sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
  }

  @protected
  KusoftSession
      sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return KusoftSessionImpl.frbInternalSseDecode(
        sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
  }

  @protected
  CallSignaling
      sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return CallSignalingImpl.frbInternalSseDecode(
        sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
  }

  @protected
  KusoftSession
      sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return KusoftSessionImpl.frbInternalSseDecode(
        sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
  }

  @protected
  CallSignaling
      sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return CallSignalingImpl.frbInternalSseDecode(
        sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
  }

  @protected
  KusoftSession
      sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return KusoftSessionImpl.frbInternalSseDecode(
        sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
  }

  @protected
  RustStreamSink<String> sse_decode_StreamSink_String_Sse(
      SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    throw UnimplementedError('Unreachable ()');
  }

  @protected
  RustStreamSink<PushEvent> sse_decode_StreamSink_push_event_Sse(
      SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    throw UnimplementedError('Unreachable ()');
  }

  @protected
  RustStreamSink<UploadEvent> sse_decode_StreamSink_upload_event_Sse(
      SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    throw UnimplementedError('Unreachable ()');
  }

  @protected
  RustStreamSink<WireLogEvent> sse_decode_StreamSink_wire_log_event_Sse(
      SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    throw UnimplementedError('Unreachable ()');
  }

  @protected
  String sse_decode_String(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var inner = sse_decode_list_prim_u_8_strict(deserializer);
    return utf8.decoder.convert(inner);
  }

  @protected
  bool sse_decode_bool(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return deserializer.buffer.getUint8() != 0;
  }

  @protected
  bool sse_decode_box_autoadd_bool(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return (sse_decode_bool(deserializer));
  }

  @protected
  CallParams sse_decode_box_autoadd_call_params(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return (sse_decode_call_params(deserializer));
  }

  @protected
  PlatformInt64 sse_decode_box_autoadd_i_64(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return (sse_decode_i_64(deserializer));
  }

  @protected
  SessionOptions sse_decode_box_autoadd_session_options(
      SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return (sse_decode_session_options(deserializer));
  }

  @protected
  CallParams sse_decode_call_params(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var var_token = sse_decode_String(deserializer);
    var var_wsEndpoint = sse_decode_String(deserializer);
    var var_stun = sse_decode_opt_String(deserializer);
    var var_turn = sse_decode_list_String(deserializer);
    var var_turnUser = sse_decode_opt_String(deserializer);
    var var_turnPassword = sse_decode_opt_String(deserializer);
    var var_isVideo = sse_decode_bool(deserializer);
    return CallParams(
        token: var_token,
        wsEndpoint: var_wsEndpoint,
        stun: var_stun,
        turn: var_turn,
        turnUser: var_turnUser,
        turnPassword: var_turnPassword,
        isVideo: var_isVideo);
  }

  @protected
  HandshakeInfo sse_decode_handshake_info(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var var_callsSeed = sse_decode_opt_box_autoadd_i_64(deserializer);
    var var_deviceName = sse_decode_opt_String(deserializer);
    var var_payload = sse_decode_list_prim_u_8_strict(deserializer);
    var var_payloadJson = sse_decode_String(deserializer);
    return HandshakeInfo(
        callsSeed: var_callsSeed,
        deviceName: var_deviceName,
        payload: var_payload,
        payloadJson: var_payloadJson);
  }

  @protected
  PlatformInt64 sse_decode_i_64(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return deserializer.buffer.getPlatformInt64();
  }

  @protected
  List<String> sse_decode_list_String(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    var len_ = sse_decode_i_32(deserializer);
    var ans_ = <String>[];
    for (var idx_ = 0; idx_ < len_; ++idx_) {
      ans_.add(sse_decode_String(deserializer));
    }
    return ans_;
  }

  @protected
  List<int> sse_decode_list_prim_u_8_loose(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var len_ = sse_decode_i_32(deserializer);
    return deserializer.buffer.getUint8List(len_);
  }

  @protected
  Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var len_ = sse_decode_i_32(deserializer);
    return deserializer.buffer.getUint8List(len_);
  }

  @protected
  RustStreamSink<WireLogEvent>? sse_decode_opt_StreamSink_wire_log_event_Sse(
      SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    if (sse_decode_bool(deserializer)) {
      return (sse_decode_StreamSink_wire_log_event_Sse(deserializer));
    } else {
      return null;
    }
  }

  @protected
  String? sse_decode_opt_String(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    if (sse_decode_bool(deserializer)) {
      return (sse_decode_String(deserializer));
    } else {
      return null;
    }
  }

  @protected
  bool? sse_decode_opt_box_autoadd_bool(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    if (sse_decode_bool(deserializer)) {
      return (sse_decode_box_autoadd_bool(deserializer));
    } else {
      return null;
    }
  }

  @protected
  CallParams? sse_decode_opt_box_autoadd_call_params(
      SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    if (sse_decode_bool(deserializer)) {
      return (sse_decode_box_autoadd_call_params(deserializer));
    } else {
      return null;
    }
  }

  @protected
  PlatformInt64? sse_decode_opt_box_autoadd_i_64(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    if (sse_decode_bool(deserializer)) {
      return (sse_decode_box_autoadd_i_64(deserializer));
    } else {
      return null;
    }
  }

  @protected
  PushEvent sse_decode_push_event(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var var_opcode = sse_decode_u_16(deserializer);
    var var_payload = sse_decode_list_prim_u_8_strict(deserializer);
    var var_payloadJson = sse_decode_String(deserializer);
    return PushEvent(
        opcode: var_opcode, payload: var_payload, payloadJson: var_payloadJson);
  }

  @protected
  RequestOutcome sse_decode_request_outcome(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var var_cmd = sse_decode_u_8(deserializer);
    var var_opcode = sse_decode_u_16(deserializer);
    var var_payloadJson = sse_decode_String(deserializer);
    var var_errorMessage = sse_decode_opt_String(deserializer);
    var var_errorKey = sse_decode_opt_String(deserializer);
    return RequestOutcome(
        cmd: var_cmd,
        opcode: var_opcode,
        payloadJson: var_payloadJson,
        errorMessage: var_errorMessage,
        errorKey: var_errorKey);
  }

  @protected
  SessionOptions sse_decode_session_options(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var var_host = sse_decode_String(deserializer);
    var var_port = sse_decode_u_16(deserializer);
    var var_deviceId = sse_decode_String(deserializer);
    var var_instanceId = sse_decode_String(deserializer);
    var var_appVersion = sse_decode_String(deserializer);
    var var_buildNumber = sse_decode_i_64(deserializer);
    var var_deviceType = sse_decode_String(deserializer);
    var var_osVersion = sse_decode_String(deserializer);
    var var_timezone = sse_decode_String(deserializer);
    var var_screen = sse_decode_String(deserializer);
    var var_pushDeviceType = sse_decode_String(deserializer);
    var var_arch = sse_decode_String(deserializer);
    var var_locale = sse_decode_String(deserializer);
    var var_deviceName = sse_decode_String(deserializer);
    var var_deviceLocale = sse_decode_String(deserializer);
    var var_clientSessionId = sse_decode_i_64(deserializer);
    var var_pingIntervalSecs = sse_decode_u_64(deserializer);
    var var_pingInteractive = sse_decode_bool(deserializer);
    var var_autoReconnect = sse_decode_bool(deserializer);
    var var_insecureTls = sse_decode_bool(deserializer);
    var var_proxy = sse_decode_opt_String(deserializer);
    var var_isPwa = sse_decode_opt_box_autoadd_bool(deserializer);
    var var_headerUserAgent = sse_decode_opt_String(deserializer);
    return SessionOptions(
        host: var_host,
        port: var_port,
        deviceId: var_deviceId,
        instanceId: var_instanceId,
        appVersion: var_appVersion,
        buildNumber: var_buildNumber,
        deviceType: var_deviceType,
        osVersion: var_osVersion,
        timezone: var_timezone,
        screen: var_screen,
        pushDeviceType: var_pushDeviceType,
        arch: var_arch,
        locale: var_locale,
        deviceName: var_deviceName,
        deviceLocale: var_deviceLocale,
        clientSessionId: var_clientSessionId,
        pingIntervalSecs: var_pingIntervalSecs,
        pingInteractive: var_pingInteractive,
        autoReconnect: var_autoReconnect,
        insecureTls: var_insecureTls,
        proxy: var_proxy,
        isPwa: var_isPwa,
        headerUserAgent: var_headerUserAgent);
  }

  @protected
  int sse_decode_u_16(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return deserializer.buffer.getUint16();
  }

  @protected
  int sse_decode_u_32(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return deserializer.buffer.getUint32();
  }

  @protected
  BigInt sse_decode_u_64(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return deserializer.buffer.getBigUint64();
  }

  @protected
  int sse_decode_u_8(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return deserializer.buffer.getUint8();
  }

  @protected
  void sse_decode_unit(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
  }

  @protected
  UploadEvent sse_decode_upload_event(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    var tag_ = sse_decode_i_32(deserializer);
    switch (tag_) {
      case 0:
        var var_sent = sse_decode_u_64(deserializer);
        var var_total = sse_decode_u_64(deserializer);
        return UploadEvent_Progress(sent: var_sent, total: var_total);
      case 1:
        var var_status = sse_decode_u_16(deserializer);
        var var_body = sse_decode_list_prim_u_8_strict(deserializer);
        return UploadEvent_Done(status: var_status, body: var_body);
      case 2:
        var var_message = sse_decode_String(deserializer);
        return UploadEvent_Error(message: var_message);
      default:
        throw UnimplementedError('');
    }
  }

  @protected
  BigInt sse_decode_usize(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return deserializer.buffer.getBigUint64();
  }

  @protected
  WireLogEvent sse_decode_wire_log_event(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    var var_direction = sse_decode_String(deserializer);
    var var_cmd = sse_decode_String(deserializer);
    var var_opcode = sse_decode_u_16(deserializer);
    var var_seq = sse_decode_u_16(deserializer);
    var var_json = sse_decode_String(deserializer);
    return WireLogEvent(
        direction: var_direction,
        cmd: var_cmd,
        opcode: var_opcode,
        seq: var_seq,
        json: var_json);
  }

  @protected
  int sse_decode_i_32(SseDeserializer deserializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    return deserializer.buffer.getInt32();
  }

  @protected
  void sse_encode_AnyhowException(
      AnyhowException self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_String(self.message, serializer);
  }

  @protected
  void
      sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          CallSignaling self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_usize(
        (self as CallSignalingImpl).frbInternalSseEncode(move: true),
        serializer);
  }

  @protected
  void
      sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          KusoftSession self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_usize(
        (self as KusoftSessionImpl).frbInternalSseEncode(move: true),
        serializer);
  }

  @protected
  void
      sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          CallSignaling self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_usize(
        (self as CallSignalingImpl).frbInternalSseEncode(move: false),
        serializer);
  }

  @protected
  void
      sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          KusoftSession self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_usize(
        (self as KusoftSessionImpl).frbInternalSseEncode(move: false),
        serializer);
  }

  @protected
  void
      sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCallSignaling(
          CallSignaling self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_usize(
        (self as CallSignalingImpl).frbInternalSseEncode(move: null),
        serializer);
  }

  @protected
  void
      sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerKusoftSession(
          KusoftSession self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_usize(
        (self as KusoftSessionImpl).frbInternalSseEncode(move: null),
        serializer);
  }

  @protected
  void sse_encode_StreamSink_String_Sse(
      RustStreamSink<String> self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_String(
        self.setupAndSerialize(
            codec: SseCodec(
          decodeSuccessData: sse_decode_String,
          decodeErrorData: sse_decode_AnyhowException,
        )),
        serializer);
  }

  @protected
  void sse_encode_StreamSink_push_event_Sse(
      RustStreamSink<PushEvent> self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_String(
        self.setupAndSerialize(
            codec: SseCodec(
          decodeSuccessData: sse_decode_push_event,
          decodeErrorData: sse_decode_AnyhowException,
        )),
        serializer);
  }

  @protected
  void sse_encode_StreamSink_upload_event_Sse(
      RustStreamSink<UploadEvent> self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_String(
        self.setupAndSerialize(
            codec: SseCodec(
          decodeSuccessData: sse_decode_upload_event,
          decodeErrorData: sse_decode_AnyhowException,
        )),
        serializer);
  }

  @protected
  void sse_encode_StreamSink_wire_log_event_Sse(
      RustStreamSink<WireLogEvent> self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_String(
        self.setupAndSerialize(
            codec: SseCodec(
          decodeSuccessData: sse_decode_wire_log_event,
          decodeErrorData: sse_decode_AnyhowException,
        )),
        serializer);
  }

  @protected
  void sse_encode_String(String self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer);
  }

  @protected
  void sse_encode_bool(bool self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    serializer.buffer.putUint8(self ? 1 : 0);
  }

  @protected
  void sse_encode_box_autoadd_bool(bool self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_bool(self, serializer);
  }

  @protected
  void sse_encode_box_autoadd_call_params(
      CallParams self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_call_params(self, serializer);
  }

  @protected
  void sse_encode_box_autoadd_i_64(
      PlatformInt64 self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_i_64(self, serializer);
  }

  @protected
  void sse_encode_box_autoadd_session_options(
      SessionOptions self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_session_options(self, serializer);
  }

  @protected
  void sse_encode_call_params(CallParams self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_String(self.token, serializer);
    sse_encode_String(self.wsEndpoint, serializer);
    sse_encode_opt_String(self.stun, serializer);
    sse_encode_list_String(self.turn, serializer);
    sse_encode_opt_String(self.turnUser, serializer);
    sse_encode_opt_String(self.turnPassword, serializer);
    sse_encode_bool(self.isVideo, serializer);
  }

  @protected
  void sse_encode_handshake_info(HandshakeInfo self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_opt_box_autoadd_i_64(self.callsSeed, serializer);
    sse_encode_opt_String(self.deviceName, serializer);
    sse_encode_list_prim_u_8_strict(self.payload, serializer);
    sse_encode_String(self.payloadJson, serializer);
  }

  @protected
  void sse_encode_i_64(PlatformInt64 self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    serializer.buffer.putPlatformInt64(self);
  }

  @protected
  void sse_encode_list_String(List<String> self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_i_32(self.length, serializer);
    for (final item in self) {
      sse_encode_String(item, serializer);
    }
  }

  @protected
  void sse_encode_list_prim_u_8_loose(
      List<int> self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_i_32(self.length, serializer);
    serializer.buffer
        .putUint8List(self is Uint8List ? self : Uint8List.fromList(self));
  }

  @protected
  void sse_encode_list_prim_u_8_strict(
      Uint8List self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_i_32(self.length, serializer);
    serializer.buffer.putUint8List(self);
  }

  @protected
  void sse_encode_opt_StreamSink_wire_log_event_Sse(
      RustStreamSink<WireLogEvent>? self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    sse_encode_bool(self != null, serializer);
    if (self != null) {
      sse_encode_StreamSink_wire_log_event_Sse(self, serializer);
    }
  }

  @protected
  void sse_encode_opt_String(String? self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    sse_encode_bool(self != null, serializer);
    if (self != null) {
      sse_encode_String(self, serializer);
    }
  }

  @protected
  void sse_encode_opt_box_autoadd_bool(bool? self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    sse_encode_bool(self != null, serializer);
    if (self != null) {
      sse_encode_box_autoadd_bool(self, serializer);
    }
  }

  @protected
  void sse_encode_opt_box_autoadd_call_params(
      CallParams? self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    sse_encode_bool(self != null, serializer);
    if (self != null) {
      sse_encode_box_autoadd_call_params(self, serializer);
    }
  }

  @protected
  void sse_encode_opt_box_autoadd_i_64(
      PlatformInt64? self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs

    sse_encode_bool(self != null, serializer);
    if (self != null) {
      sse_encode_box_autoadd_i_64(self, serializer);
    }
  }

  @protected
  void sse_encode_push_event(PushEvent self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_u_16(self.opcode, serializer);
    sse_encode_list_prim_u_8_strict(self.payload, serializer);
    sse_encode_String(self.payloadJson, serializer);
  }

  @protected
  void sse_encode_request_outcome(
      RequestOutcome self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_u_8(self.cmd, serializer);
    sse_encode_u_16(self.opcode, serializer);
    sse_encode_String(self.payloadJson, serializer);
    sse_encode_opt_String(self.errorMessage, serializer);
    sse_encode_opt_String(self.errorKey, serializer);
  }

  @protected
  void sse_encode_session_options(
      SessionOptions self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_String(self.host, serializer);
    sse_encode_u_16(self.port, serializer);
    sse_encode_String(self.deviceId, serializer);
    sse_encode_String(self.instanceId, serializer);
    sse_encode_String(self.appVersion, serializer);
    sse_encode_i_64(self.buildNumber, serializer);
    sse_encode_String(self.deviceType, serializer);
    sse_encode_String(self.osVersion, serializer);
    sse_encode_String(self.timezone, serializer);
    sse_encode_String(self.screen, serializer);
    sse_encode_String(self.pushDeviceType, serializer);
    sse_encode_String(self.arch, serializer);
    sse_encode_String(self.locale, serializer);
    sse_encode_String(self.deviceName, serializer);
    sse_encode_String(self.deviceLocale, serializer);
    sse_encode_i_64(self.clientSessionId, serializer);
    sse_encode_u_64(self.pingIntervalSecs, serializer);
    sse_encode_bool(self.pingInteractive, serializer);
    sse_encode_bool(self.autoReconnect, serializer);
    sse_encode_bool(self.insecureTls, serializer);
    sse_encode_opt_String(self.proxy, serializer);
    sse_encode_opt_box_autoadd_bool(self.isPwa, serializer);
    sse_encode_opt_String(self.headerUserAgent, serializer);
  }

  @protected
  void sse_encode_u_16(int self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    serializer.buffer.putUint16(self);
  }

  @protected
  void sse_encode_u_32(int self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    serializer.buffer.putUint32(self);
  }

  @protected
  void sse_encode_u_64(BigInt self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    serializer.buffer.putBigUint64(self);
  }

  @protected
  void sse_encode_u_8(int self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    serializer.buffer.putUint8(self);
  }

  @protected
  void sse_encode_unit(void self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
  }

  @protected
  void sse_encode_upload_event(UploadEvent self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    switch (self) {
      case UploadEvent_Progress(sent: final sent, total: final total):
        sse_encode_i_32(0, serializer);
        sse_encode_u_64(sent, serializer);
        sse_encode_u_64(total, serializer);
      case UploadEvent_Done(status: final status, body: final body):
        sse_encode_i_32(1, serializer);
        sse_encode_u_16(status, serializer);
        sse_encode_list_prim_u_8_strict(body, serializer);
      case UploadEvent_Error(message: final message):
        sse_encode_i_32(2, serializer);
        sse_encode_String(message, serializer);
    }
  }

  @protected
  void sse_encode_usize(BigInt self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    serializer.buffer.putBigUint64(self);
  }

  @protected
  void sse_encode_wire_log_event(WireLogEvent self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    sse_encode_String(self.direction, serializer);
    sse_encode_String(self.cmd, serializer);
    sse_encode_u_16(self.opcode, serializer);
    sse_encode_u_16(self.seq, serializer);
    sse_encode_String(self.json, serializer);
  }

  @protected
  void sse_encode_i_32(int self, SseSerializer serializer) {
    // Codec=Sse (Serialization based), see doc to use other codecs
    serializer.buffer.putInt32(self);
  }
}

@sealed
class CallSignalingImpl extends RustOpaque implements CallSignaling {
  // Not to be used by end users
  CallSignalingImpl.frbInternalDcoDecode(List<dynamic> wire)
      : super.frbInternalDcoDecode(wire, _kStaticData);

  // Not to be used by end users
  CallSignalingImpl.frbInternalSseDecode(BigInt ptr, int externalSizeOnNative)
      : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData);

  static final _kStaticData = RustArcStaticData(
    rustArcIncrementStrongCount:
        RustLib.instance.api.rust_arc_increment_strong_count_CallSignaling,
    rustArcDecrementStrongCount:
        RustLib.instance.api.rust_arc_decrement_strong_count_CallSignaling,
    rustArcDecrementStrongCountPtr:
        RustLib.instance.api.rust_arc_decrement_strong_count_CallSignalingPtr,
  );

  void close() => RustLib.instance.api.crateApiCallSignalingClose(
        that: this,
      );

  bool isConnected() => RustLib.instance.api.crateApiCallSignalingIsConnected(
        that: this,
      );

  Stream<String> notifications() =>
      RustLib.instance.api.crateApiCallSignalingNotifications(
        that: this,
      );

  Future<String> sendCommand(
          {required String command, required String extraJson}) =>
      RustLib.instance.api.crateApiCallSignalingSendCommand(
          that: this, command: command, extraJson: extraJson);
}

@sealed
class KusoftSessionImpl extends RustOpaque implements KusoftSession {
  // Not to be used by end users
  KusoftSessionImpl.frbInternalDcoDecode(List<dynamic> wire)
      : super.frbInternalDcoDecode(wire, _kStaticData);

  // Not to be used by end users
  KusoftSessionImpl.frbInternalSseDecode(BigInt ptr, int externalSizeOnNative)
      : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData);

  static final _kStaticData = RustArcStaticData(
    rustArcIncrementStrongCount:
        RustLib.instance.api.rust_arc_increment_strong_count_KusoftSession,
    rustArcDecrementStrongCount:
        RustLib.instance.api.rust_arc_decrement_strong_count_KusoftSession,
    rustArcDecrementStrongCountPtr:
        RustLib.instance.api.rust_arc_decrement_strong_count_KusoftSessionPtr,
  );

  Future<HandshakeInfo> connect() =>
      RustLib.instance.api.crateApiKusoftSessionConnect(
        that: this,
      );

  void disconnect() => RustLib.instance.api.crateApiKusoftSessionDisconnect(
        that: this,
      );

  bool pingInteractive() =>
      RustLib.instance.api.crateApiKusoftSessionPingInteractive(
        that: this,
      );

  Stream<PushEvent> pushes() =>
      RustLib.instance.api.crateApiKusoftSessionPushes(
        that: this,
      );

  Future<Uint8List> request(
          {required int opcode, required List<int> payload}) =>
      RustLib.instance.api.crateApiKusoftSessionRequest(
          that: this, opcode: opcode, payload: payload);

  Future<RequestOutcome> requestFull(
          {required int opcode, required String jsonIn}) =>
      RustLib.instance.api.crateApiKusoftSessionRequestFull(
          that: this, opcode: opcode, jsonIn: jsonIn);

  Future<String> requestJson({required int opcode, required String jsonIn}) =>
      RustLib.instance.api.crateApiKusoftSessionRequestJson(
          that: this, opcode: opcode, jsonIn: jsonIn);

  int send({required int opcode, required List<int> payload}) => RustLib
      .instance.api
      .crateApiKusoftSessionSend(that: this, opcode: opcode, payload: payload);

  void setPingInteractive({required bool interactive}) =>
      RustLib.instance.api.crateApiKusoftSessionSetPingInteractive(
          that: this, interactive: interactive);

  String state() => RustLib.instance.api.crateApiKusoftSessionState(
        that: this,
      );

  Stream<UploadEvent> uploadFile(
          {required String url,
          required List<int> data,
          required String filename,
          String? userAgent}) =>
      RustLib.instance.api.crateApiKusoftSessionUploadFile(
          that: this,
          url: url,
          data: data,
          filename: filename,
          userAgent: userAgent);

  Stream<UploadEvent> uploadFilePath(
          {required String url,
          required String path,
          required String filename,
          String? contentType,
          String? connection,
          String? userAgent}) =>
      RustLib.instance.api.crateApiKusoftSessionUploadFilePath(
          that: this,
          url: url,
          path: path,
          filename: filename,
          contentType: contentType,
          connection: connection,
          userAgent: userAgent);

  Stream<UploadEvent> uploadPhoto(
          {required String url,
          required List<int> data,
          required String filename,
          String? userAgent}) =>
      RustLib.instance.api.crateApiKusoftSessionUploadPhoto(
          that: this,
          url: url,
          data: data,
          filename: filename,
          userAgent: userAgent);

  Stream<UploadEvent> uploadPhotoPath(
          {required String url,
          required String path,
          required String filename,
          String? userAgent}) =>
      RustLib.instance.api.crateApiKusoftSessionUploadPhotoPath(
          that: this,
          url: url,
          path: path,
          filename: filename,
          userAgent: userAgent);

  Stream<UploadEvent> uploadVideoPath(
          {required String url,
          required String path,
          required int chunkSize,
          required int concurrency}) =>
      RustLib.instance.api.crateApiKusoftSessionUploadVideoPath(
          that: this,
          url: url,
          path: path,
          chunkSize: chunkSize,
          concurrency: concurrency);

  String userAgent() => RustLib.instance.api.crateApiKusoftSessionUserAgent(
        that: this,
      );
}
