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

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
import 'package:localsend_isolates/rust/api/model.dart';
import 'package:localsend_isolates/rust/api/stream.dart';
import 'package:localsend_isolates/rust/frb_generated.dart';

part 'http.freezed.dart';

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

RsHttpClient createClient({required String privateKey, required String cert, required LsHttpClientVersion version, int? timeoutMs}) =>
    RustLib.instance.api.crateApiHttpCreateClient(privateKey: privateKey, cert: cert, version: version, timeoutMs: timeoutMs);

RsCancellationToken createCancellationToken() => RustLib.instance.api.crateApiHttpCreateCancellationToken();

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<RsCancellationToken>>
abstract class RsCancellationToken implements RustOpaqueInterface {
  void cancel();
}

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<RsHttpClient>>
abstract class RsHttpClient implements RustOpaqueInterface {
  Future<void> cancel({required ProtocolType protocol, required String ip, required int port, required String sessionId});

  Future<PrepareUploadResult> prepareUpload({
    required ProtocolType protocol,
    required String ip,
    required int port,
    required PrepareUploadRequestDto payload,
    String? publicKey,
    String? pin,
  });

  Future<ResultWithPublicKeyRegisterResponseDto> register({
    required ProtocolType protocol,
    required String ip,
    required int port,
    required RegisterDto payload,
  });

  Stream<double> upload({
    required ProtocolType protocol,
    required String ip,
    required int port,
    String? publicKey,
    required String sessionId,
    required String fileId,
    required String token,
    Dart2RustStreamReceiver? binary,
    String? path,
    int? fileDescriptor,
    required BigInt contentLength,
    required RsCancellationToken cancelToken,
  });
}

enum LsHttpClientVersion {
  v2,
  v3,
}

class PrepareUploadResult {
  final int statusCode;
  final PrepareUploadResponseDto? response;

  const PrepareUploadResult({
    required this.statusCode,
    this.response,
  });

  @override
  int get hashCode => statusCode.hashCode ^ response.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is PrepareUploadResult && runtimeType == other.runtimeType && statusCode == other.statusCode && response == other.response;
}

class ResultWithPublicKeyRegisterResponseDto {
  final String? publicKey;
  final RegisterResponseDto body;

  const ResultWithPublicKeyRegisterResponseDto({
    this.publicKey,
    required this.body,
  });

  @override
  int get hashCode => publicKey.hashCode ^ body.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is ResultWithPublicKeyRegisterResponseDto && runtimeType == other.runtimeType && publicKey == other.publicKey && body == other.body;
}

@freezed
sealed class RsHttpClientError with _$RsHttpClientError implements FrbException {
  const RsHttpClientError._();

  const factory RsHttpClientError.statusCode({
    required int status,
    String? message,
  }) = RsHttpClientError_StatusCode;
  const factory RsHttpClientError.reqwest(
    String field0,
  ) = RsHttpClientError_Reqwest;
  const factory RsHttpClientError.json(
    String field0,
  ) = RsHttpClientError_Json;
  const factory RsHttpClientError.io(
    String field0,
  ) = RsHttpClientError_Io;
  const factory RsHttpClientError.other(
    String field0,
  ) = RsHttpClientError_Other;
}
