content: // This file is automatically generated, so please do not edit it.
  // @generated by `flutter_rust_bridge`@ 2.10.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,
    }) async {
      await instance.initImpl(
        api: api,
        handler: handler,
        externalLibrary: externalLibrary,
      );
    }
  
    /// 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.10.0';
  
    @override
    int get rustContentHash => -489908251;
  
    static const kDefaultExternalLibraryLoaderConfig =
        ExternalLibraryLoaderConfig(
      stem: 'rust',
      ioDirectory: 'rust/target/release/',
      webPrefix: 'pkg/',
    );
  }
  
  abstract class RustLibApi extends BaseApi {
    Future<Uint8List> crateApiDecryptXchacha20Poly1305(
        {required List<int> key,
        required List<int> nonce,
        required List<int> ciphertext});
  
    Future<Uint8List> crateApiEncryptXchacha20Poly1305(
        {required List<int> key,
        required List<int> nonce,
        required List<int> plaintext});
  
    Future<BaoResult> crateApiHashBaoFile({required String path});
  
    Future<BaoResult> crateApiHashBaoMemory({required List<int> bytes});
  
    Future<Uint8List> crateApiHashBlake3({required List<int> input});
  
    Future<Uint8List> crateApiHashBlake3File({required String path});
  
    Uint8List crateApiHashBlake3Sync({required List<int> input});
  
    Future<int> crateApiVerifyIntegrity(
        {required List<int> chunkBytes,
        required BigInt offset,
        required List<int> baoOutboardBytes,
        required U8Array32 blake3Hash});
  }
  
  class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
    RustLibApiImpl({
      required super.handler,
      required super.wire,
      required super.generalizedFrbRustBinding,
      required super.portManager,
    });
  
    @override
    Future<Uint8List> crateApiDecryptXchacha20Poly1305(
        {required List<int> key,
        required List<int> nonce,
        required List<int> ciphertext}) {
      return handler.executeNormal(NormalTask(
        callFfi: (port_) {
          final serializer = SseSerializer(generalizedFrbRustBinding);
          sse_encode_list_prim_u_8_loose(key, serializer);
          sse_encode_list_prim_u_8_loose(nonce, serializer);
          sse_encode_list_prim_u_8_loose(ciphertext, serializer);
          pdeCallFfi(generalizedFrbRustBinding, serializer,
              funcId: 1, port: port_);
        },
        codec: SseCodec(
          decodeSuccessData: sse_decode_list_prim_u_8_strict,
          decodeErrorData: sse_decode_AnyhowException,
        ),
        constMeta: kCrateApiDecryptXchacha20Poly1305ConstMeta,
        argValues: [key, nonce, ciphertext],
        apiImpl: this,
      ));
    }
  
    TaskConstMeta get kCrateApiDecryptXchacha20Poly1305ConstMeta =>
        const TaskConstMeta(
          debugName: "decrypt_xchacha20poly1305",
          argNames: ["key", "nonce", "ciphertext"],
        );
  
    @override
    Future<Uint8List> crateApiEncryptXchacha20Poly1305(
        {required List<int> key,
        required List<int> nonce,
        required List<int> plaintext}) {
      return handler.executeNormal(NormalTask(
        callFfi: (port_) {
          final serializer = SseSerializer(generalizedFrbRustBinding);
          sse_encode_list_prim_u_8_loose(key, serializer);
          sse_encode_list_prim_u_8_loose(nonce, serializer);
          sse_encode_list_prim_u_8_loose(plaintext, serializer);
          pdeCallFfi(generalizedFrbRustBinding, serializer,
              funcId: 2, port: port_);
        },
        codec: SseCodec(
          decodeSuccessData: sse_decode_list_prim_u_8_strict,
          decodeErrorData: sse_decode_AnyhowException,
        ),
        constMeta: kCrateApiEncryptXchacha20Poly1305ConstMeta,
        argValues: [key, nonce, plaintext],
        apiImpl: this,
      ));
    }
  
    TaskConstMeta get kCrateApiEncryptXchacha20Poly1305ConstMeta =>
        const TaskConstMeta(
          debugName: "encrypt_xchacha20poly1305",
          argNames: ["key", "nonce", "plaintext"],
        );
  
    @override
    Future<BaoResult> crateApiHashBaoFile({required String path}) {
      return handler.executeNormal(NormalTask(
        callFfi: (port_) {
          final serializer = SseSerializer(generalizedFrbRustBinding);
          sse_encode_String(path, serializer);
          pdeCallFfi(generalizedFrbRustBinding, serializer,
              funcId: 3, port: port_);
        },
        codec: SseCodec(
          decodeSuccessData: sse_decode_bao_result,
          decodeErrorData: sse_decode_AnyhowException,
        ),
        constMeta: kCrateApiHashBaoFileConstMeta,
        argValues: [path],
        apiImpl: this,
      ));
    }
  
    TaskConstMeta get kCrateApiHashBaoFileConstMeta => const TaskConstMeta(
          debugName: "hash_bao_file",
          argNames: ["path"],
        );
  
    @override
    Future<BaoResult> crateApiHashBaoMemory({required List<int> bytes}) {
      return handler.executeNormal(NormalTask(
        callFfi: (port_) {
          final serializer = SseSerializer(generalizedFrbRustBinding);
          sse_encode_list_prim_u_8_loose(bytes, serializer);
          pdeCallFfi(generalizedFrbRustBinding, serializer,
              funcId: 4, port: port_);
        },
        codec: SseCodec(
          decodeSuccessData: sse_decode_bao_result,
          decodeErrorData: sse_decode_AnyhowException,
        ),
        constMeta: kCrateApiHashBaoMemoryConstMeta,
        argValues: [bytes],
        apiImpl: this,
      ));
    }
  
    TaskConstMeta get kCrateApiHashBaoMemoryConstMeta => const TaskConstMeta(
          debugName: "hash_bao_memory",
          argNames: ["bytes"],
        );
  
    @override
    Future<Uint8List> crateApiHashBlake3({required List<int> input}) {
      return handler.executeNormal(NormalTask(
        callFfi: (port_) {
          final serializer = SseSerializer(generalizedFrbRustBinding);
          sse_encode_list_prim_u_8_loose(input, serializer);
          pdeCallFfi(generalizedFrbRustBinding, serializer,
              funcId: 5, port: port_);
        },
        codec: SseCodec(
          decodeSuccessData: sse_decode_list_prim_u_8_strict,
          decodeErrorData: sse_decode_AnyhowException,
        ),
        constMeta: kCrateApiHashBlake3ConstMeta,
        argValues: [input],
        apiImpl: this,
      ));
    }
  
    TaskConstMeta get kCrateApiHashBlake3ConstMeta => const TaskConstMeta(
          debugName: "hash_blake3",
          argNames: ["input"],
        );
  
    @override
    Future<Uint8List> crateApiHashBlake3File({required String path}) {
      return handler.executeNormal(NormalTask(
        callFfi: (port_) {
          final serializer = SseSerializer(generalizedFrbRustBinding);
          sse_encode_String(path, serializer);
          pdeCallFfi(generalizedFrbRustBinding, serializer,
              funcId: 6, port: port_);
        },
        codec: SseCodec(
          decodeSuccessData: sse_decode_list_prim_u_8_strict,
          decodeErrorData: sse_decode_AnyhowException,
        ),
        constMeta: kCrateApiHashBlake3FileConstMeta,
        argValues: [path],
        apiImpl: this,
      ));
    }
  
    TaskConstMeta get kCrateApiHashBlake3FileConstMeta => const TaskConstMeta(
          debugName: "hash_blake3_file",
          argNames: ["path"],
        );
  
    @override
    Uint8List crateApiHashBlake3Sync({required List<int> input}) {
      return handler.executeSync(SyncTask(
        callFfi: () {
          final serializer = SseSerializer(generalizedFrbRustBinding);
          sse_encode_list_prim_u_8_loose(input, serializer);
          return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 7)!;
        },
        codec: SseCodec(
          decodeSuccessData: sse_decode_list_prim_u_8_strict,
          decodeErrorData: null,
        ),
        constMeta: kCrateApiHashBlake3SyncConstMeta,
        argValues: [input],
        apiImpl: this,
      ));
    }
  
    TaskConstMeta get kCrateApiHashBlake3SyncConstMeta => const TaskConstMeta(
          debugName: "hash_blake3_sync",
          argNames: ["input"],
        );
  
    @override
    Future<int> crateApiVerifyIntegrity(
        {required List<int> chunkBytes,
        required BigInt offset,
        required List<int> baoOutboardBytes,
        required U8Array32 blake3Hash}) {
      return handler.executeNormal(NormalTask(
        callFfi: (port_) {
          final serializer = SseSerializer(generalizedFrbRustBinding);
          sse_encode_list_prim_u_8_loose(chunkBytes, serializer);
          sse_encode_u_64(offset, serializer);
          sse_encode_list_prim_u_8_loose(baoOutboardBytes, serializer);
          sse_encode_u_8_array_32(blake3Hash, serializer);
          pdeCallFfi(generalizedFrbRustBinding, serializer,
              funcId: 8, port: port_);
        },
        codec: SseCodec(
          decodeSuccessData: sse_decode_u_8,
          decodeErrorData: sse_decode_AnyhowException,
        ),
        constMeta: kCrateApiVerifyIntegrityConstMeta,
        argValues: [chunkBytes, offset, baoOutboardBytes, blake3Hash],
        apiImpl: this,
      ));
    }
  
    TaskConstMeta get kCrateApiVerifyIntegrityConstMeta => const TaskConstMeta(
          debugName: "verify_integrity",
          argNames: ["chunkBytes", "offset", "baoOutboardBytes", "blake3Hash"],
        );
  
    @protected
    AnyhowException dco_decode_AnyhowException(dynamic raw) {
      // Codec=Dco (DartCObject based), see doc to use other codecs
      return AnyhowException(raw as String);
    }
  
    @protected
    String dco_decode_String(dynamic raw) {
      // Codec=Dco (DartCObject based), see doc to use other codecs
      return raw as String;
    }
  
    @protected
    BaoResult dco_decode_bao_result(dynamic raw) {
      // Codec=Dco (DartCObject based), see doc to use other codecs
      final arr = raw as List<dynamic>;
      if (arr.length != 2)
        throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
      return BaoResult(
        hash: dco_decode_list_prim_u_8_strict(arr[0]),
        outboard: dco_decode_list_prim_u_8_strict(arr[1]),
      );
    }
  
    @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
    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
    U8Array32 dco_decode_u_8_array_32(dynamic raw) {
      // Codec=Dco (DartCObject based), see doc to use other codecs
      return U8Array32(dco_decode_list_prim_u_8_strict(raw));
    }
  
    @protected
    void dco_decode_unit(dynamic raw) {
      // Codec=Dco (DartCObject based), see doc to use other codecs
      return;
    }
  
    @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
    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
    BaoResult sse_decode_bao_result(SseDeserializer deserializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
      var var_hash = sse_decode_list_prim_u_8_strict(deserializer);
      var var_outboard = sse_decode_list_prim_u_8_strict(deserializer);
      return BaoResult(hash: var_hash, outboard: var_outboard);
    }
  
    @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
    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
    U8Array32 sse_decode_u_8_array_32(SseDeserializer deserializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
      var inner = sse_decode_list_prim_u_8_strict(deserializer);
      return U8Array32(inner);
    }
  
    @protected
    void sse_decode_unit(SseDeserializer deserializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
    }
  
    @protected
    int sse_decode_i_32(SseDeserializer deserializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
      return deserializer.buffer.getInt32();
    }
  
    @protected
    bool sse_decode_bool(SseDeserializer deserializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
      return deserializer.buffer.getUint8() != 0;
    }
  
    @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_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_bao_result(BaoResult self, SseSerializer serializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
      sse_encode_list_prim_u_8_strict(self.hash, serializer);
      sse_encode_list_prim_u_8_strict(self.outboard, 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_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_u_8_array_32(U8Array32 self, SseSerializer serializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
      sse_encode_list_prim_u_8_strict(self.inner, serializer);
    }
  
    @protected
    void sse_encode_unit(void self, SseSerializer serializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
    }
  
    @protected
    void sse_encode_i_32(int self, SseSerializer serializer) {
      // Codec=Sse (Serialization based), see doc to use other codecs
      serializer.buffer.putInt32(self);
    }
  
    @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);
    }
  }
  