2023-11-04 22:55:48 +08:00
|
|
|
// AUTO GENERATED FILE, DO NOT EDIT.
|
|
|
|
// Generated by `flutter_rust_bridge`@ 1.82.3.
|
|
|
|
// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const
|
|
|
|
|
|
|
|
import "bridge_definitions.dart";
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:meta/meta.dart';
|
|
|
|
import 'package:flutter_rust_bridge/flutter_rust_bridge.dart';
|
|
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:meta/meta.dart';
|
|
|
|
import 'package:flutter_rust_bridge/flutter_rust_bridge.dart';
|
|
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
|
|
|
|
import 'dart:ffi' as ffi;
|
|
|
|
|
|
|
|
class RustImpl implements Rust {
|
|
|
|
final RustPlatform _platform;
|
|
|
|
factory RustImpl(ExternalLibrary dylib) => RustImpl.raw(RustPlatform(dylib));
|
|
|
|
|
|
|
|
/// Only valid on web/WASM platforms.
|
|
|
|
factory RustImpl.wasm(FutureOr<WasmModule> module) =>
|
|
|
|
RustImpl(module as ExternalLibrary);
|
|
|
|
RustImpl.raw(this._platform);
|
2023-11-05 15:56:48 +08:00
|
|
|
Future<String> ping({dynamic hint}) {
|
2023-11-04 22:55:48 +08:00
|
|
|
return _platform.executeNormal(FlutterRustBridgeTask(
|
2023-11-05 15:56:48 +08:00
|
|
|
callFfi: (port_) => _platform.inner.wire_ping(port_),
|
|
|
|
parseSuccessData: _wire2api_String,
|
2023-11-04 22:55:48 +08:00
|
|
|
parseErrorData: null,
|
2023-11-05 15:56:48 +08:00
|
|
|
constMeta: kPingConstMeta,
|
2023-11-04 22:55:48 +08:00
|
|
|
argValues: [],
|
|
|
|
hint: hint,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
FlutterRustBridgeTaskConstMeta get kPingConstMeta =>
|
2023-11-04 22:55:48 +08:00
|
|
|
const FlutterRustBridgeTaskConstMeta(
|
2023-11-05 15:56:48 +08:00
|
|
|
debugName: "ping",
|
2023-11-04 22:55:48 +08:00
|
|
|
argNames: [],
|
|
|
|
);
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
Stream<DownloadCallbackData> startDownload(
|
|
|
|
{required String url,
|
|
|
|
required String savePath,
|
|
|
|
required String fileName,
|
|
|
|
required int connectionCount,
|
|
|
|
dynamic hint}) {
|
|
|
|
var arg0 = _platform.api2wire_String(url);
|
|
|
|
var arg1 = _platform.api2wire_String(savePath);
|
|
|
|
var arg2 = _platform.api2wire_String(fileName);
|
|
|
|
var arg3 = api2wire_u8(connectionCount);
|
|
|
|
return _platform.executeStream(FlutterRustBridgeTask(
|
|
|
|
callFfi: (port_) =>
|
|
|
|
_platform.inner.wire_start_download(port_, arg0, arg1, arg2, arg3),
|
|
|
|
parseSuccessData: _wire2api_download_callback_data,
|
2023-11-04 22:55:48 +08:00
|
|
|
parseErrorData: null,
|
2023-11-05 15:56:48 +08:00
|
|
|
constMeta: kStartDownloadConstMeta,
|
|
|
|
argValues: [url, savePath, fileName, connectionCount],
|
2023-11-04 22:55:48 +08:00
|
|
|
hint: hint,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
FlutterRustBridgeTaskConstMeta get kStartDownloadConstMeta =>
|
2023-11-04 22:55:48 +08:00
|
|
|
const FlutterRustBridgeTaskConstMeta(
|
2023-11-05 15:56:48 +08:00
|
|
|
debugName: "start_download",
|
|
|
|
argNames: ["url", "savePath", "fileName", "connectionCount"],
|
2023-11-04 22:55:48 +08:00
|
|
|
);
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
Future<void> cancelDownload({required String id, dynamic hint}) {
|
|
|
|
var arg0 = _platform.api2wire_String(id);
|
2023-11-04 22:55:48 +08:00
|
|
|
return _platform.executeNormal(FlutterRustBridgeTask(
|
2023-11-05 15:56:48 +08:00
|
|
|
callFfi: (port_) => _platform.inner.wire_cancel_download(port_, arg0),
|
|
|
|
parseSuccessData: _wire2api_unit,
|
2023-11-04 22:55:48 +08:00
|
|
|
parseErrorData: null,
|
2023-11-05 15:56:48 +08:00
|
|
|
constMeta: kCancelDownloadConstMeta,
|
|
|
|
argValues: [id],
|
2023-11-04 22:55:48 +08:00
|
|
|
hint: hint,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
FlutterRustBridgeTaskConstMeta get kCancelDownloadConstMeta =>
|
2023-11-04 22:55:48 +08:00
|
|
|
const FlutterRustBridgeTaskConstMeta(
|
2023-11-05 15:56:48 +08:00
|
|
|
debugName: "cancel_download",
|
|
|
|
argNames: ["id"],
|
2023-11-04 22:55:48 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
void dispose() {
|
|
|
|
_platform.dispose();
|
|
|
|
}
|
|
|
|
// Section: wire2api
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
String _wire2api_String(dynamic raw) {
|
|
|
|
return raw as String;
|
|
|
|
}
|
|
|
|
|
|
|
|
DownloadCallbackData _wire2api_download_callback_data(dynamic raw) {
|
|
|
|
final arr = raw as List<dynamic>;
|
|
|
|
if (arr.length != 5)
|
|
|
|
throw Exception('unexpected arr length: expect 5 but see ${arr.length}');
|
|
|
|
return DownloadCallbackData(
|
|
|
|
id: _wire2api_String(arr[0]),
|
|
|
|
total: _wire2api_u64(arr[1]),
|
|
|
|
progress: _wire2api_u64(arr[2]),
|
|
|
|
speed: _wire2api_u64(arr[3]),
|
|
|
|
status: _wire2api_my_downloader_status(arr[4]),
|
|
|
|
);
|
2023-11-04 22:55:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int _wire2api_i32(dynamic raw) {
|
|
|
|
return raw as int;
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
MyDownloaderStatus _wire2api_my_downloader_status(dynamic raw) {
|
|
|
|
switch (raw[0]) {
|
|
|
|
case 0:
|
|
|
|
return MyDownloaderStatus_NoStart();
|
|
|
|
case 1:
|
|
|
|
return MyDownloaderStatus_Running();
|
|
|
|
case 2:
|
|
|
|
return MyDownloaderStatus_Pending(
|
|
|
|
_wire2api_my_network_item_pending_type(raw[1]),
|
|
|
|
);
|
|
|
|
case 3:
|
|
|
|
return MyDownloaderStatus_Error(
|
|
|
|
_wire2api_String(raw[1]),
|
|
|
|
);
|
|
|
|
case 4:
|
|
|
|
return MyDownloaderStatus_Finished();
|
|
|
|
default:
|
|
|
|
throw Exception("unreachable");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MyNetworkItemPendingType _wire2api_my_network_item_pending_type(dynamic raw) {
|
|
|
|
return MyNetworkItemPendingType.values[raw as int];
|
2023-11-04 22:55:48 +08:00
|
|
|
}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
int _wire2api_u64(dynamic raw) {
|
2023-11-04 22:55:48 +08:00
|
|
|
return castInt(raw);
|
|
|
|
}
|
2023-11-05 15:56:48 +08:00
|
|
|
|
|
|
|
int _wire2api_u8(dynamic raw) {
|
|
|
|
return raw as int;
|
|
|
|
}
|
|
|
|
|
|
|
|
Uint8List _wire2api_uint_8_list(dynamic raw) {
|
|
|
|
return raw as Uint8List;
|
|
|
|
}
|
|
|
|
|
|
|
|
void _wire2api_unit(dynamic raw) {
|
|
|
|
return;
|
|
|
|
}
|
2023-11-04 22:55:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Section: api2wire
|
|
|
|
|
|
|
|
@protected
|
2023-11-05 15:56:48 +08:00
|
|
|
int api2wire_u8(int raw) {
|
2023-11-04 22:55:48 +08:00
|
|
|
return raw;
|
|
|
|
}
|
2023-11-05 15:56:48 +08:00
|
|
|
|
2023-11-04 22:55:48 +08:00
|
|
|
// Section: finalizer
|
|
|
|
|
|
|
|
class RustPlatform extends FlutterRustBridgeBase<RustWire> {
|
|
|
|
RustPlatform(ffi.DynamicLibrary dylib) : super(RustWire(dylib));
|
|
|
|
|
|
|
|
// Section: api2wire
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
@protected
|
|
|
|
ffi.Pointer<wire_uint_8_list> api2wire_String(String raw) {
|
|
|
|
return api2wire_uint_8_list(utf8.encoder.convert(raw));
|
|
|
|
}
|
|
|
|
|
|
|
|
@protected
|
|
|
|
ffi.Pointer<wire_uint_8_list> api2wire_uint_8_list(Uint8List raw) {
|
|
|
|
final ans = inner.new_uint_8_list_0(raw.length);
|
|
|
|
ans.ref.ptr.asTypedList(raw.length).setAll(0, raw);
|
|
|
|
return ans;
|
|
|
|
}
|
2023-11-04 22:55:48 +08:00
|
|
|
// Section: finalizer
|
|
|
|
|
|
|
|
// Section: api_fill_to_wire
|
|
|
|
}
|
|
|
|
|
|
|
|
// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names
|
|
|
|
|
|
|
|
// AUTO GENERATED FILE, DO NOT EDIT.
|
|
|
|
//
|
|
|
|
// Generated by `package:ffigen`.
|
|
|
|
// ignore_for_file: type=lint
|
|
|
|
|
|
|
|
/// generated by flutter_rust_bridge
|
|
|
|
class RustWire implements FlutterRustBridgeWireBase {
|
|
|
|
@internal
|
|
|
|
late final dartApi = DartApiDl(init_frb_dart_api_dl);
|
|
|
|
|
|
|
|
/// Holds the symbol lookup function.
|
|
|
|
final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
|
|
|
|
_lookup;
|
|
|
|
|
|
|
|
/// The symbols are looked up in [dynamicLibrary].
|
|
|
|
RustWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup;
|
|
|
|
|
|
|
|
/// The symbols are looked up with [lookup].
|
|
|
|
RustWire.fromLookup(
|
|
|
|
ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
|
|
|
|
lookup)
|
|
|
|
: _lookup = lookup;
|
|
|
|
|
|
|
|
void store_dart_post_cobject(
|
|
|
|
DartPostCObjectFnType ptr,
|
|
|
|
) {
|
|
|
|
return _store_dart_post_cobject(
|
|
|
|
ptr,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
late final _store_dart_post_cobjectPtr =
|
|
|
|
_lookup<ffi.NativeFunction<ffi.Void Function(DartPostCObjectFnType)>>(
|
|
|
|
'store_dart_post_cobject');
|
|
|
|
late final _store_dart_post_cobject = _store_dart_post_cobjectPtr
|
|
|
|
.asFunction<void Function(DartPostCObjectFnType)>();
|
|
|
|
|
|
|
|
Object get_dart_object(
|
|
|
|
int ptr,
|
|
|
|
) {
|
|
|
|
return _get_dart_object(
|
|
|
|
ptr,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
late final _get_dart_objectPtr =
|
|
|
|
_lookup<ffi.NativeFunction<ffi.Handle Function(ffi.UintPtr)>>(
|
|
|
|
'get_dart_object');
|
|
|
|
late final _get_dart_object =
|
|
|
|
_get_dart_objectPtr.asFunction<Object Function(int)>();
|
|
|
|
|
|
|
|
void drop_dart_object(
|
|
|
|
int ptr,
|
|
|
|
) {
|
|
|
|
return _drop_dart_object(
|
|
|
|
ptr,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
late final _drop_dart_objectPtr =
|
|
|
|
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.UintPtr)>>(
|
|
|
|
'drop_dart_object');
|
|
|
|
late final _drop_dart_object =
|
|
|
|
_drop_dart_objectPtr.asFunction<void Function(int)>();
|
|
|
|
|
|
|
|
int new_dart_opaque(
|
|
|
|
Object handle,
|
|
|
|
) {
|
|
|
|
return _new_dart_opaque(
|
|
|
|
handle,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
late final _new_dart_opaquePtr =
|
|
|
|
_lookup<ffi.NativeFunction<ffi.UintPtr Function(ffi.Handle)>>(
|
|
|
|
'new_dart_opaque');
|
|
|
|
late final _new_dart_opaque =
|
|
|
|
_new_dart_opaquePtr.asFunction<int Function(Object)>();
|
|
|
|
|
|
|
|
int init_frb_dart_api_dl(
|
|
|
|
ffi.Pointer<ffi.Void> obj,
|
|
|
|
) {
|
|
|
|
return _init_frb_dart_api_dl(
|
|
|
|
obj,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
late final _init_frb_dart_api_dlPtr =
|
|
|
|
_lookup<ffi.NativeFunction<ffi.IntPtr Function(ffi.Pointer<ffi.Void>)>>(
|
|
|
|
'init_frb_dart_api_dl');
|
|
|
|
late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr
|
|
|
|
.asFunction<int Function(ffi.Pointer<ffi.Void>)>();
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
void wire_ping(
|
2023-11-04 22:55:48 +08:00
|
|
|
int port_,
|
|
|
|
) {
|
2023-11-05 15:56:48 +08:00
|
|
|
return _wire_ping(
|
2023-11-04 22:55:48 +08:00
|
|
|
port_,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
late final _wire_pingPtr =
|
|
|
|
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64)>>('wire_ping');
|
|
|
|
late final _wire_ping = _wire_pingPtr.asFunction<void Function(int)>();
|
2023-11-04 22:55:48 +08:00
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
void wire_start_download(
|
2023-11-04 22:55:48 +08:00
|
|
|
int port_,
|
2023-11-05 15:56:48 +08:00
|
|
|
ffi.Pointer<wire_uint_8_list> url,
|
|
|
|
ffi.Pointer<wire_uint_8_list> save_path,
|
|
|
|
ffi.Pointer<wire_uint_8_list> file_name,
|
|
|
|
int connection_count,
|
2023-11-04 22:55:48 +08:00
|
|
|
) {
|
2023-11-05 15:56:48 +08:00
|
|
|
return _wire_start_download(
|
2023-11-04 22:55:48 +08:00
|
|
|
port_,
|
2023-11-05 15:56:48 +08:00
|
|
|
url,
|
|
|
|
save_path,
|
|
|
|
file_name,
|
|
|
|
connection_count,
|
2023-11-04 22:55:48 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
late final _wire_start_downloadPtr = _lookup<
|
2023-11-04 22:55:48 +08:00
|
|
|
ffi.NativeFunction<
|
2023-11-05 15:56:48 +08:00
|
|
|
ffi.Void Function(
|
|
|
|
ffi.Int64,
|
|
|
|
ffi.Pointer<wire_uint_8_list>,
|
|
|
|
ffi.Pointer<wire_uint_8_list>,
|
|
|
|
ffi.Pointer<wire_uint_8_list>,
|
|
|
|
ffi.Uint8)>>('wire_start_download');
|
|
|
|
late final _wire_start_download = _wire_start_downloadPtr.asFunction<
|
|
|
|
void Function(int, ffi.Pointer<wire_uint_8_list>,
|
|
|
|
ffi.Pointer<wire_uint_8_list>, ffi.Pointer<wire_uint_8_list>, int)>();
|
|
|
|
|
|
|
|
void wire_cancel_download(
|
2023-11-04 22:55:48 +08:00
|
|
|
int port_,
|
2023-11-05 15:56:48 +08:00
|
|
|
ffi.Pointer<wire_uint_8_list> id,
|
2023-11-04 22:55:48 +08:00
|
|
|
) {
|
2023-11-05 15:56:48 +08:00
|
|
|
return _wire_cancel_download(
|
2023-11-04 22:55:48 +08:00
|
|
|
port_,
|
2023-11-05 15:56:48 +08:00
|
|
|
id,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
late final _wire_cancel_downloadPtr = _lookup<
|
|
|
|
ffi.NativeFunction<
|
|
|
|
ffi.Void Function(ffi.Int64,
|
|
|
|
ffi.Pointer<wire_uint_8_list>)>>('wire_cancel_download');
|
|
|
|
late final _wire_cancel_download = _wire_cancel_downloadPtr
|
|
|
|
.asFunction<void Function(int, ffi.Pointer<wire_uint_8_list>)>();
|
|
|
|
|
|
|
|
ffi.Pointer<wire_uint_8_list> new_uint_8_list_0(
|
|
|
|
int len,
|
|
|
|
) {
|
|
|
|
return _new_uint_8_list_0(
|
|
|
|
len,
|
2023-11-04 22:55:48 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
late final _new_uint_8_list_0Ptr = _lookup<
|
|
|
|
ffi
|
|
|
|
.NativeFunction<ffi.Pointer<wire_uint_8_list> Function(ffi.Int32)>>(
|
|
|
|
'new_uint_8_list_0');
|
|
|
|
late final _new_uint_8_list_0 = _new_uint_8_list_0Ptr
|
|
|
|
.asFunction<ffi.Pointer<wire_uint_8_list> Function(int)>();
|
2023-11-04 22:55:48 +08:00
|
|
|
|
|
|
|
void free_WireSyncReturn(
|
|
|
|
WireSyncReturn ptr,
|
|
|
|
) {
|
|
|
|
return _free_WireSyncReturn(
|
|
|
|
ptr,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
late final _free_WireSyncReturnPtr =
|
|
|
|
_lookup<ffi.NativeFunction<ffi.Void Function(WireSyncReturn)>>(
|
|
|
|
'free_WireSyncReturn');
|
|
|
|
late final _free_WireSyncReturn =
|
|
|
|
_free_WireSyncReturnPtr.asFunction<void Function(WireSyncReturn)>();
|
|
|
|
}
|
|
|
|
|
|
|
|
final class _Dart_Handle extends ffi.Opaque {}
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
final class wire_uint_8_list extends ffi.Struct {
|
|
|
|
external ffi.Pointer<ffi.Uint8> ptr;
|
|
|
|
|
|
|
|
@ffi.Int32()
|
|
|
|
external int len;
|
|
|
|
}
|
|
|
|
|
2023-11-04 22:55:48 +08:00
|
|
|
typedef DartPostCObjectFnType = ffi.Pointer<
|
|
|
|
ffi.NativeFunction<
|
|
|
|
ffi.Bool Function(DartPort port_id, ffi.Pointer<ffi.Void> message)>>;
|
|
|
|
typedef DartPort = ffi.Int64;
|