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

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../frb_generated.dart';
import 'error.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

// These functions are ignored because they are not marked as `pub`: `proofs`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `fmt`, `from_str`, `try_from`, `try_into`, `try_into`

/// Create a token from raw proof data without network access.
/// Uses CDK's CdkToken::new to produce a valid V4 (cashuB) token.
/// `proofs_json` is a JSON array of proofs: [{"id":"...","amount":1,"secret":"...","C":"..."}, ...]
Token createOfflineToken({
  required String mintUrl,
  required String proofsJson,
  String? memo,
  String? unit,
}) => RustLib.instance.api.crateApiTokenCreateOfflineToken(
  mintUrl: mintUrl,
  proofsJson: proofsJson,
  memo: memo,
  unit: unit,
);

List<String> encodeQrToken({required Token token, BigInt? maxFragmentLength}) =>
    RustLib.instance.api.crateApiTokenEncodeQrToken(
      token: token,
      maxFragmentLength: maxFragmentLength,
    );

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<TokenDecoder>>
abstract class TokenDecoder implements RustOpaqueInterface {
  bool isComplete();

  factory TokenDecoder() => RustLib.instance.api.crateApiTokenTokenDecoderNew();

  void receive({required String input});

  Token? value();
}

class Token {
  final String encoded;
  final Uint8List? raw;
  final BigInt amount;
  final String mintUrl;

  const Token({
    required this.encoded,
    this.raw,
    required this.amount,
    required this.mintUrl,
  });

  static Token fromRawBytes({required List<int> raw}) =>
      RustLib.instance.api.crateApiTokenTokenFromRawBytes(raw: raw);

  static Token parse({required String encoded}) =>
      RustLib.instance.api.crateApiTokenTokenParse(encoded: encoded);

  @override
  int get hashCode =>
      encoded.hashCode ^ raw.hashCode ^ amount.hashCode ^ mintUrl.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is Token &&
          runtimeType == other.runtimeType &&
          encoded == other.encoded &&
          raw == other.raw &&
          amount == other.amount &&
          mintUrl == other.mintUrl;
}
