app/lib/common/rust/frb_generated.dart
2024-09-04 17:18:13 +08:00

588 lines
18 KiB
Dart

// This file is automatically generated, so please do not edit it.
// Generated by `flutter_rust_bridge`@ 2.3.0.
// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field
import 'api/http_api.dart';
import 'dart:async';
import 'dart:convert';
import 'frb_generated.dart';
import 'frb_generated.io.dart'
if (dart.library.js_interop) 'frb_generated.web.dart';
import 'http_package.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
/// Main entrypoint of the Rust API
class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
@internal
static final instance = RustLib._();
RustLib._();
/// Initialize flutter_rust_bridge
static Future<void> init({
RustLibApi? api,
BaseHandler? handler,
ExternalLibrary? externalLibrary,
}) async {
await instance.initImpl(
api: api,
handler: handler,
externalLibrary: externalLibrary,
);
}
/// Initialize flutter_rust_bridge in mock mode.
/// No libraries for FFI are loaded.
static void initMock({
required RustLibApi api,
}) {
instance.initMockImpl(
api: api,
);
}
/// Dispose flutter_rust_bridge
///
/// The call to this function is optional, since flutter_rust_bridge (and everything else)
/// is automatically disposed when the app stops.
static void dispose() => instance.disposeImpl();
@override
ApiImplConstructor<RustLibApiImpl, RustLibWire> get apiImplConstructor =>
RustLibApiImpl.new;
@override
WireConstructor<RustLibWire> get wireConstructor =>
RustLibWire.fromExternalLibrary;
@override
Future<void> executeRustInitializers() async {}
@override
ExternalLibraryLoaderConfig get defaultExternalLibraryLoaderConfig =>
kDefaultExternalLibraryLoaderConfig;
@override
String get codegenVersion => '2.3.0';
@override
int get rustContentHash => -669496402;
static const kDefaultExternalLibraryLoaderConfig =
ExternalLibraryLoaderConfig(
stem: 'rust',
ioDirectory: 'rust/target/release/',
webPrefix: 'pkg/',
);
}
abstract class RustLibApi extends BaseApi {
Future<RustHttpResponse> crateApiHttpApiFetch(
{required MyMethod method,
required String url,
Map<String, String>? headers,
Uint8List? inputData});
Future<void> crateApiHttpApiSetDefaultHeader(
{required Map<String, String> headers});
}
class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
RustLibApiImpl({
required super.handler,
required super.wire,
required super.generalizedFrbRustBinding,
required super.portManager,
});
@override
Future<RustHttpResponse> crateApiHttpApiFetch(
{required MyMethod method,
required String url,
Map<String, String>? headers,
Uint8List? inputData}) {
return handler.executeNormal(NormalTask(
callFfi: (port_) {
var arg0 = cst_encode_my_method(method);
var arg1 = cst_encode_String(url);
var arg2 = cst_encode_opt_Map_String_String(headers);
var arg3 = cst_encode_opt_list_prim_u_8_strict(inputData);
return wire.wire__crate__api__http_api__fetch(
port_, arg0, arg1, arg2, arg3);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_rust_http_response,
decodeErrorData: dco_decode_AnyhowException,
),
constMeta: kCrateApiHttpApiFetchConstMeta,
argValues: [method, url, headers, inputData],
apiImpl: this,
));
}
TaskConstMeta get kCrateApiHttpApiFetchConstMeta => const TaskConstMeta(
debugName: "fetch",
argNames: ["method", "url", "headers", "inputData"],
);
@override
Future<void> crateApiHttpApiSetDefaultHeader(
{required Map<String, String> headers}) {
return handler.executeNormal(NormalTask(
callFfi: (port_) {
var arg0 = cst_encode_Map_String_String(headers);
return wire.wire__crate__api__http_api__set_default_header(port_, arg0);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_unit,
decodeErrorData: null,
),
constMeta: kCrateApiHttpApiSetDefaultHeaderConstMeta,
argValues: [headers],
apiImpl: this,
));
}
TaskConstMeta get kCrateApiHttpApiSetDefaultHeaderConstMeta =>
const TaskConstMeta(
debugName: "set_default_header",
argNames: ["headers"],
);
@protected
AnyhowException dco_decode_AnyhowException(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return AnyhowException(raw as String);
}
@protected
Map<String, String> dco_decode_Map_String_String(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return Map.fromEntries(dco_decode_list_record_string_string(raw)
.map((e) => MapEntry(e.$1, e.$2)));
}
@protected
String dco_decode_String(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw as String;
}
@protected
BigInt dco_decode_box_autoadd_u_64(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return dco_decode_u_64(raw);
}
@protected
int dco_decode_i_32(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw as int;
}
@protected
Uint8List dco_decode_list_prim_u_8_strict(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw as Uint8List;
}
@protected
List<(String, String)> dco_decode_list_record_string_string(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return (raw as List<dynamic>).map(dco_decode_record_string_string).toList();
}
@protected
MyMethod dco_decode_my_method(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return MyMethod.values[raw as int];
}
@protected
Map<String, String>? dco_decode_opt_Map_String_String(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw == null ? null : dco_decode_Map_String_String(raw);
}
@protected
BigInt? dco_decode_opt_box_autoadd_u_64(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw == null ? null : dco_decode_box_autoadd_u_64(raw);
}
@protected
Uint8List? dco_decode_opt_list_prim_u_8_strict(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw == null ? null : dco_decode_list_prim_u_8_strict(raw);
}
@protected
(String, String) dco_decode_record_string_string(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 2) {
throw Exception('Expected 2 elements, got ${arr.length}');
}
return (
dco_decode_String(arr[0]),
dco_decode_String(arr[1]),
);
}
@protected
RustHttpResponse dco_decode_rust_http_response(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 5)
throw Exception('unexpected arr length: expect 5 but see ${arr.length}');
return RustHttpResponse(
statusCode: dco_decode_u_16(arr[0]),
headers: dco_decode_Map_String_String(arr[1]),
url: dco_decode_String(arr[2]),
contentLength: dco_decode_opt_box_autoadd_u_64(arr[3]),
data: dco_decode_opt_list_prim_u_8_strict(arr[4]),
);
}
@protected
int dco_decode_u_16(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw as int;
}
@protected
BigInt dco_decode_u_64(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return dcoDecodeU64(raw);
}
@protected
int dco_decode_u_8(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw as int;
}
@protected
void dco_decode_unit(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return;
}
@protected
AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var inner = sse_decode_String(deserializer);
return AnyhowException(inner);
}
@protected
Map<String, String> sse_decode_Map_String_String(
SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var inner = sse_decode_list_record_string_string(deserializer);
return Map.fromEntries(inner.map((e) => MapEntry(e.$1, e.$2)));
}
@protected
String sse_decode_String(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var inner = sse_decode_list_prim_u_8_strict(deserializer);
return utf8.decoder.convert(inner);
}
@protected
BigInt sse_decode_box_autoadd_u_64(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return (sse_decode_u_64(deserializer));
}
@protected
int sse_decode_i_32(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getInt32();
}
@protected
Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var len_ = sse_decode_i_32(deserializer);
return deserializer.buffer.getUint8List(len_);
}
@protected
List<(String, String)> sse_decode_list_record_string_string(
SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var len_ = sse_decode_i_32(deserializer);
var ans_ = <(String, String)>[];
for (var idx_ = 0; idx_ < len_; ++idx_) {
ans_.add(sse_decode_record_string_string(deserializer));
}
return ans_;
}
@protected
MyMethod sse_decode_my_method(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var inner = sse_decode_i_32(deserializer);
return MyMethod.values[inner];
}
@protected
Map<String, String>? sse_decode_opt_Map_String_String(
SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
if (sse_decode_bool(deserializer)) {
return (sse_decode_Map_String_String(deserializer));
} else {
return null;
}
}
@protected
BigInt? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
if (sse_decode_bool(deserializer)) {
return (sse_decode_box_autoadd_u_64(deserializer));
} else {
return null;
}
}
@protected
Uint8List? sse_decode_opt_list_prim_u_8_strict(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
if (sse_decode_bool(deserializer)) {
return (sse_decode_list_prim_u_8_strict(deserializer));
} else {
return null;
}
}
@protected
(String, String) sse_decode_record_string_string(
SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var var_field0 = sse_decode_String(deserializer);
var var_field1 = sse_decode_String(deserializer);
return (var_field0, var_field1);
}
@protected
RustHttpResponse sse_decode_rust_http_response(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var var_statusCode = sse_decode_u_16(deserializer);
var var_headers = sse_decode_Map_String_String(deserializer);
var var_url = sse_decode_String(deserializer);
var var_contentLength = sse_decode_opt_box_autoadd_u_64(deserializer);
var var_data = sse_decode_opt_list_prim_u_8_strict(deserializer);
return RustHttpResponse(
statusCode: var_statusCode,
headers: var_headers,
url: var_url,
contentLength: var_contentLength,
data: var_data);
}
@protected
int sse_decode_u_16(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getUint16();
}
@protected
BigInt sse_decode_u_64(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getBigUint64();
}
@protected
int sse_decode_u_8(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getUint8();
}
@protected
void sse_decode_unit(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
}
@protected
bool sse_decode_bool(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getUint8() != 0;
}
@protected
int cst_encode_i_32(int raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return raw;
}
@protected
int cst_encode_my_method(MyMethod raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return cst_encode_i_32(raw.index);
}
@protected
int cst_encode_u_16(int raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return raw;
}
@protected
int cst_encode_u_8(int raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return raw;
}
@protected
void cst_encode_unit(void raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return raw;
}
@protected
void sse_encode_AnyhowException(
AnyhowException self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_String(self.message, serializer);
}
@protected
void sse_encode_Map_String_String(
Map<String, String> self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_list_record_string_string(
self.entries.map((e) => (e.key, e.value)).toList(), serializer);
}
@protected
void sse_encode_String(String self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer);
}
@protected
void sse_encode_box_autoadd_u_64(BigInt self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_u_64(self, serializer);
}
@protected
void sse_encode_i_32(int self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
serializer.buffer.putInt32(self);
}
@protected
void sse_encode_list_prim_u_8_strict(
Uint8List self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_i_32(self.length, serializer);
serializer.buffer.putUint8List(self);
}
@protected
void sse_encode_list_record_string_string(
List<(String, String)> self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_i_32(self.length, serializer);
for (final item in self) {
sse_encode_record_string_string(item, serializer);
}
}
@protected
void sse_encode_my_method(MyMethod self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_i_32(self.index, serializer);
}
@protected
void sse_encode_opt_Map_String_String(
Map<String, String>? self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_bool(self != null, serializer);
if (self != null) {
sse_encode_Map_String_String(self, serializer);
}
}
@protected
void sse_encode_opt_box_autoadd_u_64(BigInt? self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_bool(self != null, serializer);
if (self != null) {
sse_encode_box_autoadd_u_64(self, serializer);
}
}
@protected
void sse_encode_opt_list_prim_u_8_strict(
Uint8List? self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_bool(self != null, serializer);
if (self != null) {
sse_encode_list_prim_u_8_strict(self, serializer);
}
}
@protected
void sse_encode_record_string_string(
(String, String) self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_String(self.$1, serializer);
sse_encode_String(self.$2, serializer);
}
@protected
void sse_encode_rust_http_response(
RustHttpResponse self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_u_16(self.statusCode, serializer);
sse_encode_Map_String_String(self.headers, serializer);
sse_encode_String(self.url, serializer);
sse_encode_opt_box_autoadd_u_64(self.contentLength, serializer);
sse_encode_opt_list_prim_u_8_strict(self.data, serializer);
}
@protected
void sse_encode_u_16(int self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
serializer.buffer.putUint16(self);
}
@protected
void sse_encode_u_64(BigInt self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
serializer.buffer.putBigUint64(self);
}
@protected
void sse_encode_u_8(int self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
serializer.buffer.putUint8(self);
}
@protected
void sse_encode_unit(void self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
}
@protected
void sse_encode_bool(bool self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
serializer.buffer.putUint8(self ? 1 : 0);
}
}