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

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../frb_generated.dart';
import 'http.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'client.freezed.dart';

// These functions are ignored because they are not marked as `pub`: `apply_dns_settings`, `apply_reqwest_tls_settings`, `build_ech_tls_config`, `build_reqwest_client`, `build_root_store`, `client_for_url`, `collect_pem_certificates`, `collect_root_cert_ders`, `create_client`, `extract_https_svc_param`, `lookup_alidns_https_ech`, `lookup_ech_config`, `new_default`, `new`, `new`, `parse_alidns_https_ech_response`, `parse_private_key`, `should_try_ech`, `webpki_root_certs`
// These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `ClientRuntime`, `DynamicDnsSettings`, `DynamicResolver`, `EchClientCacheEntry`, `EchLookupResult`, `EchTransport`, `NoVerifier`, `ParsedAliDnsHttpsEch`, `StaticResolver`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `fmt`, `resolve`, `resolve`, `supported_verify_schemes`, `verify_server_cert`, `verify_tls12_signature`, `verify_tls13_signature`

DnsSettings createStaticResolverSync({required StaticDnsSettings settings}) =>
    RustLib.instance.api.crateApiClientCreateStaticResolverSync(
      settings: settings,
    );

DnsSettings createDynamicResolverSync({
  required FutureOr<List<String>> Function(String) resolver,
}) => RustLib.instance.api.crateApiClientCreateDynamicResolverSync(
  resolver: resolver,
);

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<DnsSettings>>
abstract class DnsSettings implements RustOpaqueInterface {}

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<RequestClient>>
abstract class RequestClient implements RustOpaqueInterface {}

class ClientCertificate {
  final Uint8List certificate;
  final Uint8List privateKey;

  const ClientCertificate({
    required this.certificate,
    required this.privateKey,
  });

  @override
  int get hashCode => certificate.hashCode ^ privateKey.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is ClientCertificate &&
          runtimeType == other.runtimeType &&
          certificate == other.certificate &&
          privateKey == other.privateKey;
}

class ClientSettings {
  final CookieSettings? cookieSettings;
  final HttpVersionPref httpVersionPref;
  final TimeoutSettings? timeoutSettings;
  final bool throwOnStatusCode;
  final bool enableEch;
  final bool requireEch;
  final ProxySettings? proxySettings;
  final RedirectSettings? redirectSettings;
  final TlsSettings? tlsSettings;
  final DnsSettings? dnsSettings;
  final String? userAgent;

  const ClientSettings({
    this.cookieSettings,
    required this.httpVersionPref,
    this.timeoutSettings,
    required this.throwOnStatusCode,
    required this.enableEch,
    required this.requireEch,
    this.proxySettings,
    this.redirectSettings,
    this.tlsSettings,
    this.dnsSettings,
    this.userAgent,
  });

  static Future<ClientSettings> default_() =>
      RustLib.instance.api.crateApiClientClientSettingsDefault();

  @override
  int get hashCode =>
      cookieSettings.hashCode ^
      httpVersionPref.hashCode ^
      timeoutSettings.hashCode ^
      throwOnStatusCode.hashCode ^
      enableEch.hashCode ^
      requireEch.hashCode ^
      proxySettings.hashCode ^
      redirectSettings.hashCode ^
      tlsSettings.hashCode ^
      dnsSettings.hashCode ^
      userAgent.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is ClientSettings &&
          runtimeType == other.runtimeType &&
          cookieSettings == other.cookieSettings &&
          httpVersionPref == other.httpVersionPref &&
          timeoutSettings == other.timeoutSettings &&
          throwOnStatusCode == other.throwOnStatusCode &&
          enableEch == other.enableEch &&
          requireEch == other.requireEch &&
          proxySettings == other.proxySettings &&
          redirectSettings == other.redirectSettings &&
          tlsSettings == other.tlsSettings &&
          dnsSettings == other.dnsSettings &&
          userAgent == other.userAgent;
}

class CookieSettings {
  final bool storeCookies;

  const CookieSettings({
    required this.storeCookies,
  });

  @override
  int get hashCode => storeCookies.hashCode;

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

class CustomProxy {
  final String url;
  final ProxyCondition condition;

  const CustomProxy({
    required this.url,
    required this.condition,
  });

  @override
  int get hashCode => url.hashCode ^ condition.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is CustomProxy &&
          runtimeType == other.runtimeType &&
          url == other.url &&
          condition == other.condition;
}

enum ProxyCondition {
  http,
  https,
  all,
}

@freezed
sealed class ProxySettings with _$ProxySettings {
  const ProxySettings._();

  const factory ProxySettings.noProxy() = ProxySettings_NoProxy;
  const factory ProxySettings.customProxyList(
    List<CustomProxy> field0,
  ) = ProxySettings_CustomProxyList;
}

@freezed
sealed class RedirectSettings with _$RedirectSettings {
  const RedirectSettings._();

  const factory RedirectSettings.noRedirect() = RedirectSettings_NoRedirect;
  const factory RedirectSettings.limitedRedirects(
    int field0,
  ) = RedirectSettings_LimitedRedirects;
}

enum RootCertSource {
  platform,
  webpki,
  none,
}

class StaticDnsSettings {
  final Map<String, List<String>> overrides;
  final String? fallback;

  const StaticDnsSettings({
    required this.overrides,
    this.fallback,
  });

  @override
  int get hashCode => overrides.hashCode ^ fallback.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is StaticDnsSettings &&
          runtimeType == other.runtimeType &&
          overrides == other.overrides &&
          fallback == other.fallback;
}

class TimeoutSettings {
  final Duration? timeout;
  final Duration? connectTimeout;
  final Duration? keepAliveTimeout;
  final Duration? keepAlivePing;

  const TimeoutSettings({
    this.timeout,
    this.connectTimeout,
    this.keepAliveTimeout,
    this.keepAlivePing,
  });

  @override
  int get hashCode =>
      timeout.hashCode ^
      connectTimeout.hashCode ^
      keepAliveTimeout.hashCode ^
      keepAlivePing.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is TimeoutSettings &&
          runtimeType == other.runtimeType &&
          timeout == other.timeout &&
          connectTimeout == other.connectTimeout &&
          keepAliveTimeout == other.keepAliveTimeout &&
          keepAlivePing == other.keepAlivePing;
}

class TlsSettings {
  final RootCertSource rootCertSource;
  final List<Uint8List> trustedRootCertificates;
  final bool verifyCertificates;
  final ClientCertificate? clientCertificate;
  final TlsVersion? minTlsVersion;
  final TlsVersion? maxTlsVersion;
  final bool sni;

  const TlsSettings({
    required this.rootCertSource,
    required this.trustedRootCertificates,
    required this.verifyCertificates,
    this.clientCertificate,
    this.minTlsVersion,
    this.maxTlsVersion,
    required this.sni,
  });

  @override
  int get hashCode =>
      rootCertSource.hashCode ^
      trustedRootCertificates.hashCode ^
      verifyCertificates.hashCode ^
      clientCertificate.hashCode ^
      minTlsVersion.hashCode ^
      maxTlsVersion.hashCode ^
      sni.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is TlsSettings &&
          runtimeType == other.runtimeType &&
          rootCertSource == other.rootCertSource &&
          trustedRootCertificates == other.trustedRootCertificates &&
          verifyCertificates == other.verifyCertificates &&
          clientCertificate == other.clientCertificate &&
          minTlsVersion == other.minTlsVersion &&
          maxTlsVersion == other.maxTlsVersion &&
          sni == other.sni;
}

enum TlsVersion {
  tls12,
  tls13,
}
