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

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

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

// These functions are ignored because they are not marked as `pub`: `add_filters_windows`, `add_ip_condition`, `add_network_filter`, `cleanup_windows`, `delete_filters_windows`, `get_layers_for_rule`, `initialize_windows`, `validate_rule_layer_compatibility`
// 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`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from_str`

Future<Uint16List> toWideString({required String s}) =>
    RustLib.instance.api.crateApiAstralWfpToWideString(s: s);

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<FilterRule>>
abstract class FilterRule implements RustOpaqueInterface {
  FilterAction get action;

  String? get appPath;

  Direction get direction;

  Uint64List get filterIds;

  String? get local;

  int? get localPort;

  (int, int)? get localPortRange;

  String get name;

  int get priority;

  Protocol? get protocol;

  String? get remote;

  int? get remotePort;

  (int, int)? get remotePortRange;

  set action(FilterAction action);

  set appPath(String? appPath);

  set direction(Direction direction);

  set filterIds(Uint64List filterIds);

  set local(String? local);

  set localPort(int? localPort);

  set localPortRange((int, int)? localPortRange);

  set name(String name);

  set priority(int priority);

  set protocol(Protocol? protocol);

  set remote(String? remote);

  set remotePort(int? remotePort);

  set remotePortRange((int, int)? remotePortRange);

  static Future<FilterRule> newWithParams({
    required String name,
    String? appPath,
    String? local,
    String? remote,
    int? localPort,
    int? remotePort,
    (int, int)? localPortRange,
    (int, int)? remotePortRange,
    Protocol? protocol,
    required Direction direction,
    required FilterAction action,
    int? priority,
    String? description,
  }) => RustLib.instance.api.crateApiAstralWfpFilterRuleNewWithParams(
    name: name,
    appPath: appPath,
    local: local,
    remote: remote,
    localPort: localPort,
    remotePort: remotePort,
    localPortRange: localPortRange,
    remotePortRange: remotePortRange,
    protocol: protocol,
    direction: direction,
    action: action,
    priority: priority,
    description: description,
  );

  Future<void> validate();
}

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

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<IpNetwork>>
abstract class IpNetwork implements RustOpaqueInterface {
  IpAddr get ip;

  int get prefixLen;

  set ip(IpAddr ip);

  set prefixLen(int prefixLen);

  /// 从CIDR格式字符串创建IP网段
  static Future<IpNetwork> fromCidr({required String cidr}) =>
      RustLib.instance.api.crateApiAstralWfpIpNetworkFromCidr(cidr: cidr);
}

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<WfpController>>
abstract class WfpController implements RustOpaqueInterface {
  Future<Uint64List> addFilters({required List<FilterRule> rules});

  Uint64List get filterIds;

  set filterIds(Uint64List filterIds);

  Future<void> cleanup();

  Future<int> deleteFilters({required Uint64List filterIds});

  Future<void> getLayerName({required Guid layerKey});

  Future<void> initialize();

  // HINT: Make it `#[frb(sync)]` to let it become the default constructor of Dart class.
  static Future<WfpController> newInstance() =>
      RustLib.instance.api.crateApiAstralWfpWfpControllerNew();
}

/// 网络流量方向
enum Direction { inbound, outbound, both }

/// 过滤动作类型
enum FilterAction { allow, block }

/// 网络协议类型
enum Protocol { tcp, udp }
