feat: Optimize RsProcess

This commit is contained in:
xkeyC 2024-04-17 21:40:08 +08:00
parent 603ef46f10
commit 097b9d9bce
8 changed files with 219 additions and 899 deletions

View File

@ -6,56 +6,36 @@
import '../frb_generated.dart'; import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
// Rust type: RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>> // The type `RS_PROCESS_MAP` is not used by any `pub` functions, thus it is ignored.
@sealed // The type `RsProcess` is not used by any `pub` functions, thus it is ignored.
class RsProcess extends RustOpaque {
RsProcess.dcoDecode(List<dynamic> wire) : super.dcoDecode(wire, _kStaticData);
RsProcess.sseDecode(int ptr, int externalSizeOnNative) Stream<RsProcessStreamData> start(
: super.sseDecode(ptr, externalSizeOnNative, _kStaticData); {required String executable,
required List<String> arguments,
required String workingDirectory,
dynamic hint}) =>
RustLib.instance.api.start(
executable: executable,
arguments: arguments,
workingDirectory: workingDirectory,
hint: hint);
static final _kStaticData = RustArcStaticData( Future<void> write({required int rsPid, required String data, dynamic hint}) =>
rustArcIncrementStrongCount: RustLib.instance.api.write(rsPid: rsPid, data: data, hint: hint);
RustLib.instance.api.rust_arc_increment_strong_count_RsProcess,
rustArcDecrementStrongCount:
RustLib.instance.api.rust_arc_decrement_strong_count_RsProcess,
rustArcDecrementStrongCountPtr:
RustLib.instance.api.rust_arc_decrement_strong_count_RsProcessPtr,
);
int? getPid({dynamic hint}) =>
RustLib.instance.api.rsProcessGetPid(that: this, hint: hint);
factory RsProcess({dynamic hint}) =>
RustLib.instance.api.rsProcessNew(hint: hint);
Stream<RsProcessStreamData> start(
{required String executable,
required List<String> arguments,
required String workingDirectory,
dynamic hint}) =>
RustLib.instance.api.rsProcessStart(
that: this,
executable: executable,
arguments: arguments,
workingDirectory: workingDirectory,
hint: hint);
Future<void> write({required String data, dynamic hint}) =>
RustLib.instance.api.rsProcessWrite(that: this, data: data, hint: hint);
}
class RsProcessStreamData { class RsProcessStreamData {
final RsProcessStreamDataType dataType; final RsProcessStreamDataType dataType;
final String data; final String data;
final int rsPid;
const RsProcessStreamData({ const RsProcessStreamData({
required this.dataType, required this.dataType,
required this.data, required this.data,
required this.rsPid,
}); });
@override @override
int get hashCode => dataType.hashCode ^ data.hashCode; int get hashCode => dataType.hashCode ^ data.hashCode ^ rsPid.hashCode;
@override @override
bool operator ==(Object other) => bool operator ==(Object other) =>
@ -63,7 +43,8 @@ class RsProcessStreamData {
other is RsProcessStreamData && other is RsProcessStreamData &&
runtimeType == other.runtimeType && runtimeType == other.runtimeType &&
dataType == other.dataType && dataType == other.dataType &&
data == other.data; data == other.data &&
rsPid == other.rsPid;
} }
enum RsProcessStreamDataType { enum RsProcessStreamDataType {

View File

@ -56,7 +56,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
String get codegenVersion => '2.0.0-dev.32'; String get codegenVersion => '2.0.0-dev.32';
@override @override
int get rustContentHash => 333909092; int get rustContentHash => 1270049297;
static const kDefaultExternalLibraryLoaderConfig = static const kDefaultExternalLibraryLoaderConfig =
ExternalLibraryLoaderConfig( ExternalLibraryLoaderConfig(
@ -82,27 +82,13 @@ abstract class RustLibApi extends BaseApi {
Future<void> setDefaultHeader( Future<void> setDefaultHeader(
{required Map<String, String> headers, dynamic hint}); {required Map<String, String> headers, dynamic hint});
int? rsProcessGetPid({required RsProcess that, dynamic hint}); Stream<RsProcessStreamData> start(
{required String executable,
RsProcess rsProcessNew({dynamic hint});
Stream<RsProcessStreamData> rsProcessStart(
{required RsProcess that,
required String executable,
required List<String> arguments, required List<String> arguments,
required String workingDirectory, required String workingDirectory,
dynamic hint}); dynamic hint});
Future<void> rsProcessWrite( Future<void> write({required int rsPid, required String data, dynamic hint});
{required RsProcess that, required String data, dynamic hint});
RustArcIncrementStrongCountFnType
get rust_arc_increment_strong_count_RsProcess;
RustArcDecrementStrongCountFnType
get rust_arc_decrement_strong_count_RsProcess;
CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_RsProcessPtr;
} }
class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
@ -217,160 +203,67 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
); );
@override @override
int? rsProcessGetPid({required RsProcess that, dynamic hint}) { Stream<RsProcessStreamData> start(
return handler.executeSync(SyncTask( {required String executable,
callFfi: () {
var arg0 =
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
that);
return wire.wire_RsProcess_get_pid(arg0);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_opt_box_autoadd_u_32,
decodeErrorData: null,
),
constMeta: kRsProcessGetPidConstMeta,
argValues: [that],
apiImpl: this,
hint: hint,
));
}
TaskConstMeta get kRsProcessGetPidConstMeta => const TaskConstMeta(
debugName: "RsProcess_get_pid",
argNames: ["that"],
);
@override
RsProcess rsProcessNew({dynamic hint}) {
return handler.executeSync(SyncTask(
callFfi: () {
return wire.wire_RsProcess_new();
},
codec: DcoCodec(
decodeSuccessData:
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess,
decodeErrorData: null,
),
constMeta: kRsProcessNewConstMeta,
argValues: [],
apiImpl: this,
hint: hint,
));
}
TaskConstMeta get kRsProcessNewConstMeta => const TaskConstMeta(
debugName: "RsProcess_new",
argNames: [],
);
@override
Stream<RsProcessStreamData> rsProcessStart(
{required RsProcess that,
required String executable,
required List<String> arguments, required List<String> arguments,
required String workingDirectory, required String workingDirectory,
dynamic hint}) { dynamic hint}) {
final streamSink = RustStreamSink<RsProcessStreamData>(); final streamSink = RustStreamSink<RsProcessStreamData>();
unawaited(handler.executeNormal(NormalTask( unawaited(handler.executeNormal(NormalTask(
callFfi: (port_) { callFfi: (port_) {
var arg0 = var arg0 = cst_encode_String(executable);
cst_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess( var arg1 = cst_encode_list_String(arguments);
that); var arg2 = cst_encode_String(workingDirectory);
var arg1 = cst_encode_String(executable); var arg3 = cst_encode_StreamSink_rs_process_stream_data_Dco(streamSink);
var arg2 = cst_encode_list_String(arguments); return wire.wire_start(port_, arg0, arg1, arg2, arg3);
var arg3 = cst_encode_String(workingDirectory);
var arg4 = cst_encode_StreamSink_rs_process_stream_data_Dco(streamSink);
return wire.wire_RsProcess_start(port_, arg0, arg1, arg2, arg3, arg4);
}, },
codec: DcoCodec( codec: DcoCodec(
decodeSuccessData: dco_decode_unit, decodeSuccessData: dco_decode_unit,
decodeErrorData: null, decodeErrorData: null,
), ),
constMeta: kRsProcessStartConstMeta, constMeta: kStartConstMeta,
argValues: [that, executable, arguments, workingDirectory, streamSink], argValues: [executable, arguments, workingDirectory, streamSink],
apiImpl: this, apiImpl: this,
hint: hint, hint: hint,
))); )));
return streamSink.stream; return streamSink.stream;
} }
TaskConstMeta get kRsProcessStartConstMeta => const TaskConstMeta( TaskConstMeta get kStartConstMeta => const TaskConstMeta(
debugName: "RsProcess_start", debugName: "start",
argNames: [ argNames: ["executable", "arguments", "workingDirectory", "streamSink"],
"that",
"executable",
"arguments",
"workingDirectory",
"streamSink"
],
); );
@override @override
Future<void> rsProcessWrite( Future<void> write({required int rsPid, required String data, dynamic hint}) {
{required RsProcess that, required String data, dynamic hint}) {
return handler.executeNormal(NormalTask( return handler.executeNormal(NormalTask(
callFfi: (port_) { callFfi: (port_) {
var arg0 = var arg0 = cst_encode_u_32(rsPid);
cst_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
that);
var arg1 = cst_encode_String(data); var arg1 = cst_encode_String(data);
return wire.wire_RsProcess_write(port_, arg0, arg1); return wire.wire_write(port_, arg0, arg1);
}, },
codec: DcoCodec( codec: DcoCodec(
decodeSuccessData: dco_decode_unit, decodeSuccessData: dco_decode_unit,
decodeErrorData: null, decodeErrorData: null,
), ),
constMeta: kRsProcessWriteConstMeta, constMeta: kWriteConstMeta,
argValues: [that, data], argValues: [rsPid, data],
apiImpl: this, apiImpl: this,
hint: hint, hint: hint,
)); ));
} }
TaskConstMeta get kRsProcessWriteConstMeta => const TaskConstMeta( TaskConstMeta get kWriteConstMeta => const TaskConstMeta(
debugName: "RsProcess_write", debugName: "write",
argNames: ["that", "data"], argNames: ["rsPid", "data"],
); );
RustArcIncrementStrongCountFnType
get rust_arc_increment_strong_count_RsProcess => wire
.rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess;
RustArcDecrementStrongCountFnType
get rust_arc_decrement_strong_count_RsProcess => wire
.rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess;
@protected @protected
AnyhowException dco_decode_AnyhowException(dynamic raw) { AnyhowException dco_decode_AnyhowException(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
return AnyhowException(raw as String); return AnyhowException(raw as String);
} }
@protected
RsProcess
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return RsProcess.dcoDecode(raw as List<dynamic>);
}
@protected
RsProcess
dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return RsProcess.dcoDecode(raw as List<dynamic>);
}
@protected
RsProcess
dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return RsProcess.dcoDecode(raw as List<dynamic>);
}
@protected @protected
Map<String, String> dco_decode_Map_String_String(dynamic raw) { Map<String, String> dco_decode_Map_String_String(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
@ -378,14 +271,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
.map((e) => MapEntry(e.$1, e.$2))); .map((e) => MapEntry(e.$1, e.$2)));
} }
@protected
RsProcess
dco_decode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return RsProcess.dcoDecode(raw as List<dynamic>);
}
@protected @protected
RustStreamSink<RsProcessStreamData> RustStreamSink<RsProcessStreamData>
dco_decode_StreamSink_rs_process_stream_data_Dco(dynamic raw) { dco_decode_StreamSink_rs_process_stream_data_Dco(dynamic raw) {
@ -399,12 +284,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return raw as String; return raw as String;
} }
@protected
int dco_decode_box_autoadd_u_32(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw as int;
}
@protected @protected
int dco_decode_box_autoadd_u_64(dynamic raw) { int dco_decode_box_autoadd_u_64(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
@ -459,12 +338,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return raw == null ? null : dco_decode_String(raw); return raw == null ? null : dco_decode_String(raw);
} }
@protected
int? dco_decode_opt_box_autoadd_u_32(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw == null ? null : dco_decode_box_autoadd_u_32(raw);
}
@protected @protected
int? dco_decode_opt_box_autoadd_u_64(dynamic raw) { int? dco_decode_opt_box_autoadd_u_64(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
@ -494,11 +367,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
RsProcessStreamData dco_decode_rs_process_stream_data(dynamic raw) { RsProcessStreamData dco_decode_rs_process_stream_data(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>; final arr = raw as List<dynamic>;
if (arr.length != 2) if (arr.length != 3)
throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); throw Exception('unexpected arr length: expect 3 but see ${arr.length}');
return RsProcessStreamData( return RsProcessStreamData(
dataType: dco_decode_rs_process_stream_data_type(arr[0]), dataType: dco_decode_rs_process_stream_data_type(arr[0]),
data: dco_decode_String(arr[1]), data: dco_decode_String(arr[1]),
rsPid: dco_decode_u_32(arr[2]),
); );
} }
@ -555,12 +429,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return; return;
} }
@protected
int dco_decode_usize(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return dcoDecodeI64OrU64(raw);
}
@protected @protected
AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) { AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
@ -568,33 +436,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return AnyhowException(inner); return AnyhowException(inner);
} }
@protected
RsProcess
sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return RsProcess.sseDecode(
sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
}
@protected
RsProcess
sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return RsProcess.sseDecode(
sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
}
@protected
RsProcess
sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return RsProcess.sseDecode(
sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
}
@protected @protected
Map<String, String> sse_decode_Map_String_String( Map<String, String> sse_decode_Map_String_String(
SseDeserializer deserializer) { SseDeserializer deserializer) {
@ -603,15 +444,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return Map.fromEntries(inner.map((e) => MapEntry(e.$1, e.$2))); return Map.fromEntries(inner.map((e) => MapEntry(e.$1, e.$2)));
} }
@protected
RsProcess
sse_decode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return RsProcess.sseDecode(
sse_decode_usize(deserializer), sse_decode_i_32(deserializer));
}
@protected @protected
RustStreamSink<RsProcessStreamData> RustStreamSink<RsProcessStreamData>
sse_decode_StreamSink_rs_process_stream_data_Dco( sse_decode_StreamSink_rs_process_stream_data_Dco(
@ -627,12 +459,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return utf8.decoder.convert(inner); return utf8.decoder.convert(inner);
} }
@protected
int sse_decode_box_autoadd_u_32(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return (sse_decode_u_32(deserializer));
}
@protected @protected
int sse_decode_box_autoadd_u_64(SseDeserializer deserializer) { int sse_decode_box_autoadd_u_64(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
@ -714,17 +540,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
} }
} }
@protected
int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
if (sse_decode_bool(deserializer)) {
return (sse_decode_box_autoadd_u_32(deserializer));
} else {
return null;
}
}
@protected @protected
int? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer) { int? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
@ -762,7 +577,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
var var_dataType = sse_decode_rs_process_stream_data_type(deserializer); var var_dataType = sse_decode_rs_process_stream_data_type(deserializer);
var var_data = sse_decode_String(deserializer); var var_data = sse_decode_String(deserializer);
return RsProcessStreamData(dataType: var_dataType, data: var_data); var var_rsPid = sse_decode_u_32(deserializer);
return RsProcessStreamData(
dataType: var_dataType, data: var_data, rsPid: var_rsPid);
} }
@protected @protected
@ -822,50 +639,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
} }
@protected
int sse_decode_usize(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getUint64();
}
@protected @protected
bool sse_decode_bool(SseDeserializer deserializer) { bool sse_decode_bool(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getUint8() != 0; return deserializer.buffer.getUint8() != 0;
} }
@protected
int cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
// ignore: invalid_use_of_internal_member
return raw.cstEncode(move: true);
}
@protected
int cst_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
// ignore: invalid_use_of_internal_member
return raw.cstEncode(move: false);
}
@protected
int cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
// ignore: invalid_use_of_internal_member
return raw.cstEncode(move: false);
}
@protected
int cst_encode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
// ignore: invalid_use_of_internal_member
return raw.cstEncode();
}
@protected @protected
int cst_encode_i_32(int raw) { int cst_encode_i_32(int raw) {
// Codec=Cst (C-struct based), see doc to use other codecs // Codec=Cst (C-struct based), see doc to use other codecs
@ -914,12 +693,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return raw; return raw;
} }
@protected
int cst_encode_usize(int raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return raw;
}
@protected @protected
void sse_encode_AnyhowException( void sse_encode_AnyhowException(
AnyhowException self, SseSerializer serializer) { AnyhowException self, SseSerializer serializer) {
@ -927,30 +700,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
throw UnimplementedError('Unreachable ()'); throw UnimplementedError('Unreachable ()');
} }
@protected
void
sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_usize(self.sseEncode(move: true), serializer);
}
@protected
void
sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_usize(self.sseEncode(move: false), serializer);
}
@protected
void
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_usize(self.sseEncode(move: false), serializer);
}
@protected @protected
void sse_encode_Map_String_String( void sse_encode_Map_String_String(
Map<String, String> self, SseSerializer serializer) { Map<String, String> self, SseSerializer serializer) {
@ -959,14 +708,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
self.entries.map((e) => (e.key, e.value)).toList(), serializer); self.entries.map((e) => (e.key, e.value)).toList(), serializer);
} }
@protected
void
sse_encode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_usize(self.sseEncode(move: null), serializer);
}
@protected @protected
void sse_encode_StreamSink_rs_process_stream_data_Dco( void sse_encode_StreamSink_rs_process_stream_data_Dco(
RustStreamSink<RsProcessStreamData> self, SseSerializer serializer) { RustStreamSink<RsProcessStreamData> self, SseSerializer serializer) {
@ -985,12 +726,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer); sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer);
} }
@protected
void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_u_32(self, serializer);
}
@protected @protected
void sse_encode_box_autoadd_u_64(int self, SseSerializer serializer) { void sse_encode_box_autoadd_u_64(int self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
@ -1064,16 +799,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
} }
} }
@protected
void sse_encode_opt_box_autoadd_u_32(int? 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_32(self, serializer);
}
}
@protected @protected
void sse_encode_opt_box_autoadd_u_64(int? self, SseSerializer serializer) { void sse_encode_opt_box_autoadd_u_64(int? self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
@ -1109,6 +834,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_rs_process_stream_data_type(self.dataType, serializer); sse_encode_rs_process_stream_data_type(self.dataType, serializer);
sse_encode_String(self.data, serializer); sse_encode_String(self.data, serializer);
sse_encode_u_32(self.rsPid, serializer);
} }
@protected @protected
@ -1160,12 +886,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
} }
@protected
void sse_encode_usize(int self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
serializer.buffer.putUint64(self);
}
@protected @protected
void sse_encode_bool(bool self, SseSerializer serializer) { void sse_encode_bool(bool self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs

View File

@ -20,35 +20,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
required super.portManager, required super.portManager,
}); });
CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_RsProcessPtr =>
wire._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcessPtr;
@protected @protected
AnyhowException dco_decode_AnyhowException(dynamic raw); AnyhowException dco_decode_AnyhowException(dynamic raw);
@protected
RsProcess
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
dynamic raw);
@protected
RsProcess
dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
dynamic raw);
@protected
RsProcess
dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
dynamic raw);
@protected @protected
Map<String, String> dco_decode_Map_String_String(dynamic raw); Map<String, String> dco_decode_Map_String_String(dynamic raw);
@protected
RsProcess
dco_decode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
dynamic raw);
@protected @protected
RustStreamSink<RsProcessStreamData> RustStreamSink<RsProcessStreamData>
dco_decode_StreamSink_rs_process_stream_data_Dco(dynamic raw); dco_decode_StreamSink_rs_process_stream_data_Dco(dynamic raw);
@ -56,9 +33,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
String dco_decode_String(dynamic raw); String dco_decode_String(dynamic raw);
@protected
int dco_decode_box_autoadd_u_32(dynamic raw);
@protected @protected
int dco_decode_box_autoadd_u_64(dynamic raw); int dco_decode_box_autoadd_u_64(dynamic raw);
@ -86,9 +60,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
String? dco_decode_opt_String(dynamic raw); String? dco_decode_opt_String(dynamic raw);
@protected
int? dco_decode_opt_box_autoadd_u_32(dynamic raw);
@protected @protected
int? dco_decode_opt_box_autoadd_u_64(dynamic raw); int? dco_decode_opt_box_autoadd_u_64(dynamic raw);
@ -122,36 +93,13 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
void dco_decode_unit(dynamic raw); void dco_decode_unit(dynamic raw);
@protected
int dco_decode_usize(dynamic raw);
@protected @protected
AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer);
@protected
RsProcess
sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
SseDeserializer deserializer);
@protected
RsProcess
sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
SseDeserializer deserializer);
@protected
RsProcess
sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
SseDeserializer deserializer);
@protected @protected
Map<String, String> sse_decode_Map_String_String( Map<String, String> sse_decode_Map_String_String(
SseDeserializer deserializer); SseDeserializer deserializer);
@protected
RsProcess
sse_decode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
SseDeserializer deserializer);
@protected @protected
RustStreamSink<RsProcessStreamData> RustStreamSink<RsProcessStreamData>
sse_decode_StreamSink_rs_process_stream_data_Dco( sse_decode_StreamSink_rs_process_stream_data_Dco(
@ -160,9 +108,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
String sse_decode_String(SseDeserializer deserializer); String sse_decode_String(SseDeserializer deserializer);
@protected
int sse_decode_box_autoadd_u_32(SseDeserializer deserializer);
@protected @protected
int sse_decode_box_autoadd_u_64(SseDeserializer deserializer); int sse_decode_box_autoadd_u_64(SseDeserializer deserializer);
@ -192,9 +137,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
String? sse_decode_opt_String(SseDeserializer deserializer); String? sse_decode_opt_String(SseDeserializer deserializer);
@protected
int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer);
@protected @protected
int? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer); int? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer);
@ -231,9 +173,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
void sse_decode_unit(SseDeserializer deserializer); void sse_decode_unit(SseDeserializer deserializer);
@protected
int sse_decode_usize(SseDeserializer deserializer);
@protected @protected
bool sse_decode_bool(SseDeserializer deserializer); bool sse_decode_bool(SseDeserializer deserializer);
@ -269,12 +208,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
return cst_encode_list_prim_u_8_strict(utf8.encoder.convert(raw)); return cst_encode_list_prim_u_8_strict(utf8.encoder.convert(raw));
} }
@protected
ffi.Pointer<ffi.Uint32> cst_encode_box_autoadd_u_32(int raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return wire.cst_new_box_autoadd_u_32(cst_encode_u_32(raw));
}
@protected @protected
ffi.Pointer<ffi.Uint64> cst_encode_box_autoadd_u_64(int raw) { ffi.Pointer<ffi.Uint64> cst_encode_box_autoadd_u_64(int raw) {
// Codec=Cst (C-struct based), see doc to use other codecs // Codec=Cst (C-struct based), see doc to use other codecs
@ -325,12 +258,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
return raw == null ? ffi.nullptr : cst_encode_String(raw); return raw == null ? ffi.nullptr : cst_encode_String(raw);
} }
@protected
ffi.Pointer<ffi.Uint32> cst_encode_opt_box_autoadd_u_32(int? raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return raw == null ? ffi.nullptr : cst_encode_box_autoadd_u_32(raw);
}
@protected @protected
ffi.Pointer<ffi.Uint64> cst_encode_opt_box_autoadd_u_64(int? raw) { ffi.Pointer<ffi.Uint64> cst_encode_opt_box_autoadd_u_64(int? raw) {
// Codec=Cst (C-struct based), see doc to use other codecs // Codec=Cst (C-struct based), see doc to use other codecs
@ -362,6 +289,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
RsProcessStreamData apiObj, wire_cst_rs_process_stream_data wireObj) { RsProcessStreamData apiObj, wire_cst_rs_process_stream_data wireObj) {
wireObj.data_type = cst_encode_rs_process_stream_data_type(apiObj.dataType); wireObj.data_type = cst_encode_rs_process_stream_data_type(apiObj.dataType);
wireObj.data = cst_encode_String(apiObj.data); wireObj.data = cst_encode_String(apiObj.data);
wireObj.rs_pid = cst_encode_u_32(apiObj.rsPid);
} }
@protected @protected
@ -377,22 +305,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
wireObj.data = cst_encode_opt_list_prim_u_8_strict(apiObj.data); wireObj.data = cst_encode_opt_list_prim_u_8_strict(apiObj.data);
} }
@protected
int cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess raw);
@protected
int cst_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess raw);
@protected
int cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess raw);
@protected
int cst_encode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess raw);
@protected @protected
int cst_encode_i_32(int raw); int cst_encode_i_32(int raw);
@ -417,37 +329,14 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
void cst_encode_unit(void raw); void cst_encode_unit(void raw);
@protected
int cst_encode_usize(int raw);
@protected @protected
void sse_encode_AnyhowException( void sse_encode_AnyhowException(
AnyhowException self, SseSerializer serializer); AnyhowException self, SseSerializer serializer);
@protected
void
sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess self, SseSerializer serializer);
@protected
void
sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess self, SseSerializer serializer);
@protected
void
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess self, SseSerializer serializer);
@protected @protected
void sse_encode_Map_String_String( void sse_encode_Map_String_String(
Map<String, String> self, SseSerializer serializer); Map<String, String> self, SseSerializer serializer);
@protected
void
sse_encode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
RsProcess self, SseSerializer serializer);
@protected @protected
void sse_encode_StreamSink_rs_process_stream_data_Dco( void sse_encode_StreamSink_rs_process_stream_data_Dco(
RustStreamSink<RsProcessStreamData> self, SseSerializer serializer); RustStreamSink<RsProcessStreamData> self, SseSerializer serializer);
@ -455,9 +344,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
void sse_encode_String(String self, SseSerializer serializer); void sse_encode_String(String self, SseSerializer serializer);
@protected
void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer);
@protected @protected
void sse_encode_box_autoadd_u_64(int self, SseSerializer serializer); void sse_encode_box_autoadd_u_64(int self, SseSerializer serializer);
@ -488,9 +374,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
void sse_encode_opt_String(String? self, SseSerializer serializer); void sse_encode_opt_String(String? self, SseSerializer serializer);
@protected
void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer);
@protected @protected
void sse_encode_opt_box_autoadd_u_64(int? self, SseSerializer serializer); void sse_encode_opt_box_autoadd_u_64(int? self, SseSerializer serializer);
@ -529,9 +412,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
void sse_encode_unit(void self, SseSerializer serializer); void sse_encode_unit(void self, SseSerializer serializer);
@protected
void sse_encode_usize(int self, SseSerializer serializer);
@protected @protected
void sse_encode_bool(bool self, SseSerializer serializer); void sse_encode_bool(bool self, SseSerializer serializer);
} }
@ -668,41 +548,15 @@ class RustLibWire implements BaseWire {
late final _wire_set_default_header = _wire_set_default_headerPtr.asFunction< late final _wire_set_default_header = _wire_set_default_headerPtr.asFunction<
void Function(int, ffi.Pointer<wire_cst_list_record_string_string>)>(); void Function(int, ffi.Pointer<wire_cst_list_record_string_string>)>();
WireSyncRust2DartDco wire_RsProcess_get_pid( void wire_start(
int that,
) {
return _wire_RsProcess_get_pid(
that,
);
}
late final _wire_RsProcess_get_pidPtr =
_lookup<ffi.NativeFunction<WireSyncRust2DartDco Function(ffi.UintPtr)>>(
'frbgen_starcitizen_doctor_wire_RsProcess_get_pid');
late final _wire_RsProcess_get_pid = _wire_RsProcess_get_pidPtr
.asFunction<WireSyncRust2DartDco Function(int)>();
WireSyncRust2DartDco wire_RsProcess_new() {
return _wire_RsProcess_new();
}
late final _wire_RsProcess_newPtr =
_lookup<ffi.NativeFunction<WireSyncRust2DartDco Function()>>(
'frbgen_starcitizen_doctor_wire_RsProcess_new');
late final _wire_RsProcess_new =
_wire_RsProcess_newPtr.asFunction<WireSyncRust2DartDco Function()>();
void wire_RsProcess_start(
int port_, int port_,
int that,
ffi.Pointer<wire_cst_list_prim_u_8_strict> executable, ffi.Pointer<wire_cst_list_prim_u_8_strict> executable,
ffi.Pointer<wire_cst_list_String> arguments, ffi.Pointer<wire_cst_list_String> arguments,
ffi.Pointer<wire_cst_list_prim_u_8_strict> working_directory, ffi.Pointer<wire_cst_list_prim_u_8_strict> working_directory,
ffi.Pointer<wire_cst_list_prim_u_8_strict> stream_sink, ffi.Pointer<wire_cst_list_prim_u_8_strict> stream_sink,
) { ) {
return _wire_RsProcess_start( return _wire_start(
port_, port_,
that,
executable, executable,
arguments, arguments,
working_directory, working_directory,
@ -710,91 +564,43 @@ class RustLibWire implements BaseWire {
); );
} }
late final _wire_RsProcess_startPtr = _lookup< late final _wire_startPtr = _lookup<
ffi.NativeFunction< ffi.NativeFunction<
ffi.Void Function( ffi.Void Function(
ffi.Int64, ffi.Int64,
ffi.UintPtr,
ffi.Pointer<wire_cst_list_prim_u_8_strict>, ffi.Pointer<wire_cst_list_prim_u_8_strict>,
ffi.Pointer<wire_cst_list_String>, ffi.Pointer<wire_cst_list_String>,
ffi.Pointer<wire_cst_list_prim_u_8_strict>, ffi.Pointer<wire_cst_list_prim_u_8_strict>,
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>( ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
'frbgen_starcitizen_doctor_wire_RsProcess_start'); 'frbgen_starcitizen_doctor_wire_start');
late final _wire_RsProcess_start = _wire_RsProcess_startPtr.asFunction< late final _wire_start = _wire_startPtr.asFunction<
void Function( void Function(
int,
int, int,
ffi.Pointer<wire_cst_list_prim_u_8_strict>, ffi.Pointer<wire_cst_list_prim_u_8_strict>,
ffi.Pointer<wire_cst_list_String>, ffi.Pointer<wire_cst_list_String>,
ffi.Pointer<wire_cst_list_prim_u_8_strict>, ffi.Pointer<wire_cst_list_prim_u_8_strict>,
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>(); ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
void wire_RsProcess_write( void wire_write(
int port_, int port_,
int that, int rs_pid,
ffi.Pointer<wire_cst_list_prim_u_8_strict> data, ffi.Pointer<wire_cst_list_prim_u_8_strict> data,
) { ) {
return _wire_RsProcess_write( return _wire_write(
port_, port_,
that, rs_pid,
data, data,
); );
} }
late final _wire_RsProcess_writePtr = _lookup< late final _wire_writePtr = _lookup<
ffi.NativeFunction< ffi.NativeFunction<
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Void Function(ffi.Int64, ffi.Uint32,
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>( ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
'frbgen_starcitizen_doctor_wire_RsProcess_write'); 'frbgen_starcitizen_doctor_wire_write');
late final _wire_RsProcess_write = _wire_RsProcess_writePtr.asFunction< late final _wire_write = _wire_writePtr.asFunction<
void Function(int, int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>(); void Function(int, int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
void
rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
ffi.Pointer<ffi.Void> ptr,
) {
return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
ptr,
);
}
late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcessPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
'frbgen_starcitizen_doctor_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess');
late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess =
_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcessPtr
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
void
rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
ffi.Pointer<ffi.Void> ptr,
) {
return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
ptr,
);
}
late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcessPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
'frbgen_starcitizen_doctor_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess');
late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess =
_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcessPtr
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
ffi.Pointer<ffi.Uint32> cst_new_box_autoadd_u_32(
int value,
) {
return _cst_new_box_autoadd_u_32(
value,
);
}
late final _cst_new_box_autoadd_u_32Ptr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Uint32> Function(ffi.Uint32)>>(
'frbgen_starcitizen_doctor_cst_new_box_autoadd_u_32');
late final _cst_new_box_autoadd_u_32 = _cst_new_box_autoadd_u_32Ptr
.asFunction<ffi.Pointer<ffi.Uint32> Function(int)>();
ffi.Pointer<ffi.Uint64> cst_new_box_autoadd_u_64( ffi.Pointer<ffi.Uint64> cst_new_box_autoadd_u_64(
int value, int value,
) { ) {
@ -909,6 +715,9 @@ final class wire_cst_rs_process_stream_data extends ffi.Struct {
external int data_type; external int data_type;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> data; external ffi.Pointer<wire_cst_list_prim_u_8_strict> data;
@ffi.Uint32()
external int rs_pid;
} }
final class wire_cst_rust_http_response extends ffi.Struct { final class wire_cst_rust_http_response extends ffi.Struct {

View File

@ -8,7 +8,8 @@ import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:starcitizen_doctor/api/api.dart'; import 'package:starcitizen_doctor/api/api.dart';
import 'package:starcitizen_doctor/common/helper/system_helper.dart'; import 'package:starcitizen_doctor/common/helper/system_helper.dart';
import 'package:starcitizen_doctor/common/rust/api/rs_process.dart'; import 'package:starcitizen_doctor/common/rust/api/rs_process.dart'
as rs_process;
import 'package:starcitizen_doctor/common/utils/log.dart'; import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/common/utils/provider.dart'; import 'package:starcitizen_doctor/common/utils/provider.dart';
@ -97,9 +98,7 @@ class Aria2cModel extends _$Aria2cModel {
dPrint("trackerList === $trackerList"); dPrint("trackerList === $trackerList");
dPrint("Aria2cManager .----- aria2c start $port------"); dPrint("Aria2cManager .----- aria2c start $port------");
final rsp = RsProcess(); final stream = rs_process.start(
final stream = rsp.start(
executable: exePath, executable: exePath,
arguments: [ arguments: [
"-V", "-V",
@ -124,16 +123,16 @@ class Aria2cModel extends _$Aria2cModel {
stream.listen((event) { stream.listen((event) {
dPrint("Aria2cManager.rs_process event === $event"); dPrint("Aria2cManager.rs_process event === $event");
switch (event.dataType) { switch (event.dataType) {
case RsProcessStreamDataType.output: case rs_process.RsProcessStreamDataType.output:
if (event.data.contains("IPv4 RPC: listening on TCP port")) { if (event.data.contains("IPv4 RPC: listening on TCP port")) {
_onLaunch(port, pwd, trackerList); _onLaunch(port, pwd, trackerList);
} }
break; break;
case RsProcessStreamDataType.error: case rs_process.RsProcessStreamDataType.error:
launchError = event.data; launchError = event.data;
state = state.copyWith(aria2c: null); state = state.copyWith(aria2c: null);
break; break;
case RsProcessStreamDataType.exit: case rs_process.RsProcessStreamDataType.exit:
launchError = event.data; launchError = event.data;
state = state.copyWith(aria2c: null); state = state.copyWith(aria2c: null);
break; break;

View File

@ -11,6 +11,8 @@ import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/common/utils/provider.dart'; import 'package:starcitizen_doctor/common/utils/provider.dart';
import 'package:starcitizen_doctor/data/app_unp4k_p4k_item_data.dart'; import 'package:starcitizen_doctor/data/app_unp4k_p4k_item_data.dart';
import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart'; import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart';
import 'package:starcitizen_doctor/common/rust/api/rs_process.dart'
as rs_process;
part 'unp4kc.freezed.dart'; part 'unp4kc.freezed.dart';
@ -30,7 +32,7 @@ class Unp4kcState with _$Unp4kcState {
@riverpod @riverpod
class Unp4kCModel extends _$Unp4kCModel { class Unp4kCModel extends _$Unp4kCModel {
RsProcess? _process; int? _rsPid;
@override @override
Unp4kcState build() { Unp4kcState build() {
@ -49,20 +51,17 @@ class Unp4kCModel extends _$Unp4kCModel {
await BinaryModuleConf.extractModule( await BinaryModuleConf.extractModule(
["unp4kc"], appGlobalState.applicationBinaryModuleDir!); ["unp4kc"], appGlobalState.applicationBinaryModuleDir!);
final exec = "$execDir\\unp4kc.exe"; final exec = "$execDir\\unp4kc.exe";
// final ps = await Process.start(exec, []);
// StringBuffer stringBuffer = StringBuffer();
_process = RsProcess(); final stream = rs_process.start(
final stream = _process?.start(
executable: exec, arguments: [], workingDirectory: execDir); executable: exec, arguments: [], workingDirectory: execDir);
stream?.listen((event) async { stream.listen((event) async {
_rsPid = event.rsPid;
switch (event.dataType) { switch (event.dataType) {
case RsProcessStreamDataType.output: case RsProcessStreamDataType.output:
try { try {
final eventJson = await compute(json.decode, event.data); final eventJson = await compute(json.decode, event.data);
_handleMessage(eventJson); _handleMessage(eventJson, event.rsPid);
} catch (e) { } catch (e) {
dPrint("[unp4kc] json error: $e"); dPrint("[unp4kc] json error: $e");
} }
@ -77,22 +76,21 @@ class Unp4kCModel extends _$Unp4kCModel {
}); });
ref.onDispose(() { ref.onDispose(() {
final pid = _process?.getPid(); if (_rsPid != null) {
if (pid != null) { Process.killPid(_rsPid!);
Process.killPid(pid);
dPrint("[unp4kc] kill ..."); dPrint("[unp4kc] kill ...");
} }
}); });
} }
void _handleMessage(Map<String, dynamic> eventJson) async { void _handleMessage(Map<String, dynamic> eventJson, int rsPid) async {
final action = eventJson["action"]; final action = eventJson["action"];
final data = eventJson["data"]; final data = eventJson["data"];
final gamePath = getGamePath(); final gamePath = getGamePath();
final gameP4kPath = "$gamePath\\Data.p4k"; final gameP4kPath = "$gamePath\\Data.p4k";
switch (action.toString().trim()) { switch (action.toString().trim()) {
case "info: startup": case "info: startup":
_process?.write(data: "$gameP4kPath\n"); rs_process.write(rsPid: rsPid, data: "$gameP4kPath\n");
state = state.copyWith(endMessage: "正在读取P4K 文件 ..."); state = state.copyWith(endMessage: "正在读取P4K 文件 ...");
break; break;
case "data: P4K_Files": case "data: P4K_Files":
@ -195,6 +193,9 @@ class Unp4kCModel extends _$Unp4kCModel {
} }
outputPath = "$outputPath$filePath"; outputPath = "$outputPath$filePath";
dPrint("extractFile .... $filePath"); dPrint("extractFile .... $filePath");
_process?.write(data: "$mode<:,:>$filePath<:,:>$outputPath"); if (_rsPid != null) {
rs_process.write(
rsPid: _rsPid!, data: "$mode<:,:>$filePath<:,:>$outputPath");
}
} }
} }

View File

@ -1,19 +1,17 @@
use flutter_rust_bridge::for_generated::futures::lock::Mutex; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use async_std::task::block_on;
use flutter_rust_bridge::frb; use lazy_static::lazy_static;
use scopeguard::defer;
use tokio::io::AsyncBufReadExt;
use tokio::io::AsyncWriteExt;
use tokio::io::BufReader; use tokio::io::BufReader;
use tokio::io::{AsyncBufReadExt, AsyncWriteExt};
use tokio::process::ChildStdin; use tokio::process::ChildStdin;
use tokio::sync::Mutex;
use crate::frb_generated::StreamSink; use crate::frb_generated::StreamSink;
#[frb(opaque)]
pub struct RsProcess {
child_stdin: Option<Arc<Mutex<ChildStdin>>>,
pid: Option<u32>,
}
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum RsProcessStreamDataType { pub enum RsProcessStreamDataType {
Output, Output,
@ -24,118 +22,130 @@ pub enum RsProcessStreamDataType {
pub struct RsProcessStreamData { pub struct RsProcessStreamData {
pub data_type: RsProcessStreamDataType, pub data_type: RsProcessStreamDataType,
pub data: String, pub data: String,
pub rs_pid: u32,
} }
impl RsProcess { pub struct RsProcess {
#[frb(sync)] pub child_stdin: ChildStdin,
pub fn new() -> Self { pub rs_pid: u32,
RsProcess { }
child_stdin: None,
pid: None, lazy_static! {
static ref RS_PROCESS_MAP: Mutex<HashMap<u32, RsProcess>> = Mutex::new(HashMap::new());
}
pub async fn start(
executable: String,
arguments: Vec<String>,
working_directory: String,
stream_sink: StreamSink<RsProcessStreamData>,
) {
let stream_sink_arc = Arc::from(stream_sink);
let mut command = tokio::process::Command::new(executable);
command
.args(arguments)
.current_dir(working_directory)
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.kill_on_drop(true);
command.creation_flags(0x08000000);
let job = win32job::Job::create().unwrap();
let mut info = job.query_extended_limit_info().unwrap();
info.limit_kill_on_job_close();
job.set_extended_limit_info(&mut info).unwrap();
let job_arc = Arc::from(job);
if let Ok(mut child) = command.spawn() {
{
let raw_handle = child.raw_handle();
if raw_handle.is_some() {
job_arc
.assign_process(raw_handle.unwrap() as isize)
.unwrap();
}
} }
}
pub async fn start( let stdin = child.stdin.take().expect("[rs_process] Failed to open stdin");
&mut self, let pid = child.id().expect("[rs_process] Failed to get pid");
executable: String, {
arguments: Vec<String>, let mut map = RS_PROCESS_MAP.lock().await;
working_directory: String, map.insert(
stream_sink: StreamSink<RsProcessStreamData>, pid,
) { RsProcess {
let stream_sink_arc = Arc::from(stream_sink); child_stdin: stdin,
rs_pid: pid,
},
);
}
let mut command = tokio::process::Command::new(executable); defer! {
command let mut map = block_on(RS_PROCESS_MAP.lock());
.args(arguments) map.remove(&pid);
.current_dir(working_directory) println!("RS_PROCESS_MAP ..defer ..len() = {}", map.len());
.stdin(std::process::Stdio::piped()) }
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.kill_on_drop(true);
command.creation_flags(0x08000000); let stdout = child.stdout.take().expect("[rs_process] Failed to open stdout");
let stderr = child.stderr.take().expect("[rs_process] Failed to open stderr");
let job = win32job::Job::create().unwrap(); let output_task = tokio::spawn(_process_output(
let mut info = job.query_extended_limit_info().unwrap(); stdout,
info.limit_kill_on_job_close(); stream_sink_arc.clone(),
job.set_extended_limit_info(&mut info).unwrap(); RsProcessStreamDataType::Output,
pid,
));
let error_task = tokio::spawn(_process_output(
stderr,
stream_sink_arc.clone(),
RsProcessStreamDataType::Error,
pid,
));
let job_arc = Arc::from(job); tokio::select! {_ = output_task => (), _ = error_task => () }
if let Ok(mut child) = command.spawn() { let exit_status = child
{ .wait()
let raw_handle = child.raw_handle(); .await
if raw_handle.is_some() { .expect("[rs_process] Failed to wait for child process");
job_arc
.assign_process(raw_handle.unwrap() as isize)
.unwrap();
}
}
let stdout = child.stdout.take().expect("Failed to open stdout"); if !exit_status.success() {
let stderr = child.stderr.take().expect("Failed to open stderr"); println!("[rs_process] Child process exited with an error: {:?}", exit_status);
let stdin = child.stdin.take().expect("Failed to open stdin");
self.child_stdin = Some(Arc::from(Mutex::new(stdin)));
let output_task = tokio::spawn(_process_output(
stdout,
stream_sink_arc.clone(),
RsProcessStreamDataType::Output,
));
let error_task = tokio::spawn(_process_output(
stderr,
stream_sink_arc.clone(),
RsProcessStreamDataType::Error,
));
self.pid = child.id();
tokio::select! {
_ = output_task => (),
_ = error_task => (),
}
let exit_status = child
.wait()
.await
.expect("Failed to wait for child process");
if !exit_status.success() {
eprintln!("Child process exited with an error: {:?}", exit_status);
let message = RsProcessStreamData {
data_type: RsProcessStreamDataType::Exit,
data: "exit".to_string(),
};
stream_sink_arc.add(message).unwrap();
}
} else {
eprintln!("Failed to start");
let message = RsProcessStreamData { let message = RsProcessStreamData {
data_type: RsProcessStreamDataType::Error, data_type: RsProcessStreamDataType::Exit,
data: "Failed to start".to_string(), data: "exit".to_string(),
rs_pid: pid,
}; };
stream_sink_arc.add(message).unwrap(); stream_sink_arc.add(message).unwrap();
} }
} else {
println!("Failed to start");
let message = RsProcessStreamData {
data_type: RsProcessStreamDataType::Error,
data: "Failed to start".to_string(),
rs_pid: 0,
};
stream_sink_arc.add(message).unwrap();
} }
}
pub async fn write(&mut self, data: String) { pub async fn write(rs_pid: &u32, data: String) {
if let Some(stdin) = &self.child_stdin { let mut map = RS_PROCESS_MAP.lock().await;
let mut stdin_lock = stdin.lock().await; let process = map.get_mut(rs_pid).unwrap();
stdin_lock.write_all(data.as_bytes()).await.unwrap(); process
} .child_stdin
} .write_all(data.as_bytes())
.await
#[frb(sync)] .unwrap();
pub fn get_pid(&self) -> Option<u32> {
self.pid
}
} }
async fn _process_output<R>( async fn _process_output<R>(
stdout: R, stdout: R,
stream_sink: Arc<StreamSink<RsProcessStreamData>>, stream_sink: Arc<StreamSink<RsProcessStreamData>>,
data_type: RsProcessStreamDataType, data_type: RsProcessStreamDataType,
pid: u32,
) where ) where
R: tokio::io::AsyncRead + Unpin, R: tokio::io::AsyncRead + Unpin,
{ {
@ -146,6 +156,7 @@ async fn _process_output<R>(
let message = RsProcessStreamData { let message = RsProcessStreamData {
data_type, data_type,
data: line.trim().parse().unwrap(), data: line.trim().parse().unwrap(),
rs_pid: pid,
}; };
stream_sink.add(message).unwrap(); stream_sink.add(message).unwrap();
} }

View File

@ -4,7 +4,6 @@
// Section: imports // Section: imports
use super::*; use super::*;
use crate::api::rs_process::*;
use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt};
use flutter_rust_bridge::for_generated::transform_result_dco; use flutter_rust_bridge::for_generated::transform_result_dco;
use flutter_rust_bridge::{Handler, IntoIntoDart}; use flutter_rust_bridge::{Handler, IntoIntoDart};
@ -23,12 +22,6 @@ impl CstDecode<flutter_rust_bridge::for_generated::anyhow::Error>
unimplemented!() unimplemented!()
} }
} }
impl CstDecode<RsProcess> for usize {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> RsProcess {
CstDecode::<RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>>::cst_decode(self).rust_auto_opaque_decode_owned()
}
}
impl CstDecode<std::collections::HashMap<String, String>> impl CstDecode<std::collections::HashMap<String, String>>
for *mut wire_cst_list_record_string_string for *mut wire_cst_list_record_string_string
{ {
@ -38,16 +31,6 @@ impl CstDecode<std::collections::HashMap<String, String>>
vec.into_iter().collect() vec.into_iter().collect()
} }
} }
impl CstDecode<RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>>
for usize
{
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(
self,
) -> RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>> {
unsafe { decode_rust_opaque_nom(self as _) }
}
}
impl impl
CstDecode< CstDecode<
StreamSink< StreamSink<
@ -74,12 +57,6 @@ impl CstDecode<String> for *mut wire_cst_list_prim_u_8_strict {
String::from_utf8(vec).unwrap() String::from_utf8(vec).unwrap()
} }
} }
impl CstDecode<u32> for *mut u32 {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> u32 {
unsafe { *flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }
}
}
impl CstDecode<u64> for *mut u64 { impl CstDecode<u64> for *mut u64 {
// Codec=Cst (C-struct based), see doc to use other codecs // Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> u64 { fn cst_decode(self) -> u64 {
@ -127,6 +104,7 @@ impl CstDecode<crate::api::rs_process::RsProcessStreamData> for wire_cst_rs_proc
crate::api::rs_process::RsProcessStreamData { crate::api::rs_process::RsProcessStreamData {
data_type: self.data_type.cst_decode(), data_type: self.data_type.cst_decode(),
data: self.data.cst_decode(), data: self.data.cst_decode(),
rs_pid: self.rs_pid.cst_decode(),
} }
} }
} }
@ -162,6 +140,7 @@ impl NewWithNullPtr for wire_cst_rs_process_stream_data {
Self { Self {
data_type: Default::default(), data_type: Default::default(),
data: core::ptr::null_mut(), data: core::ptr::null_mut(),
rs_pid: Default::default(),
} }
} }
} }
@ -226,67 +205,23 @@ pub extern "C" fn frbgen_starcitizen_doctor_wire_set_default_header(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn frbgen_starcitizen_doctor_wire_RsProcess_get_pid( pub extern "C" fn frbgen_starcitizen_doctor_wire_start(
that: usize,
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
wire_RsProcess_get_pid_impl(that)
}
#[no_mangle]
pub extern "C" fn frbgen_starcitizen_doctor_wire_RsProcess_new(
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
wire_RsProcess_new_impl()
}
#[no_mangle]
pub extern "C" fn frbgen_starcitizen_doctor_wire_RsProcess_start(
port_: i64, port_: i64,
that: usize,
executable: *mut wire_cst_list_prim_u_8_strict, executable: *mut wire_cst_list_prim_u_8_strict,
arguments: *mut wire_cst_list_String, arguments: *mut wire_cst_list_String,
working_directory: *mut wire_cst_list_prim_u_8_strict, working_directory: *mut wire_cst_list_prim_u_8_strict,
stream_sink: *mut wire_cst_list_prim_u_8_strict, stream_sink: *mut wire_cst_list_prim_u_8_strict,
) { ) {
wire_RsProcess_start_impl( wire_start_impl(port_, executable, arguments, working_directory, stream_sink)
port_,
that,
executable,
arguments,
working_directory,
stream_sink,
)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn frbgen_starcitizen_doctor_wire_RsProcess_write( pub extern "C" fn frbgen_starcitizen_doctor_wire_write(
port_: i64, port_: i64,
that: usize, rs_pid: u32,
data: *mut wire_cst_list_prim_u_8_strict, data: *mut wire_cst_list_prim_u_8_strict,
) { ) {
wire_RsProcess_write_impl(port_, that, data) wire_write_impl(port_, rs_pid, data)
}
#[no_mangle]
pub extern "C" fn frbgen_starcitizen_doctor_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
ptr: *const std::ffi::c_void,
) {
unsafe {
StdArc::<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>::increment_strong_count(ptr as _);
}
}
#[no_mangle]
pub extern "C" fn frbgen_starcitizen_doctor_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockRsProcess(
ptr: *const std::ffi::c_void,
) {
unsafe {
StdArc::<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>::decrement_strong_count(ptr as _);
}
}
#[no_mangle]
pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_u_32(value: u32) -> *mut u32 {
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
} }
#[no_mangle] #[no_mangle]
@ -362,6 +297,7 @@ pub struct wire_cst_record_string_string {
pub struct wire_cst_rs_process_stream_data { pub struct wire_cst_rs_process_stream_data {
data_type: i32, data_type: i32,
data: *mut wire_cst_list_prim_u_8_strict, data: *mut wire_cst_list_prim_u_8_strict,
rs_pid: u32,
} }
#[repr(C)] #[repr(C)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]

View File

@ -19,7 +19,6 @@
// Section: imports // Section: imports
use crate::api::rs_process::*;
use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt};
use flutter_rust_bridge::for_generated::transform_result_dco; use flutter_rust_bridge::for_generated::transform_result_dco;
use flutter_rust_bridge::{Handler, IntoIntoDart}; use flutter_rust_bridge::{Handler, IntoIntoDart};
@ -32,7 +31,7 @@ flutter_rust_bridge::frb_generated_boilerplate!(
default_rust_auto_opaque = RustAutoOpaqueNom, default_rust_auto_opaque = RustAutoOpaqueNom,
); );
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0-dev.32"; pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0-dev.32";
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 333909092; pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1270049297;
// Section: executor // Section: executor
@ -140,45 +139,8 @@ fn wire_set_default_header_impl(
}, },
) )
} }
fn wire_RsProcess_get_pid_impl( fn wire_start_impl(
that: impl CstDecode<
RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>,
>,
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::<flutter_rust_bridge::for_generated::DcoCodec, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "RsProcess_get_pid",
port: None,
mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync,
},
move || {
let api_that = that.cst_decode();
transform_result_dco((move || {
let api_that = api_that.rust_auto_opaque_decode_ref();
Result::<_, ()>::Ok(crate::api::rs_process::RsProcess::get_pid(&api_that))
})())
},
)
}
fn wire_RsProcess_new_impl() -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::<flutter_rust_bridge::for_generated::DcoCodec, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "RsProcess_new",
port: None,
mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync,
},
move || {
transform_result_dco((move || {
Result::<_, ()>::Ok(crate::api::rs_process::RsProcess::new())
})())
},
)
}
fn wire_RsProcess_start_impl(
port_: flutter_rust_bridge::for_generated::MessagePort, port_: flutter_rust_bridge::for_generated::MessagePort,
that: impl CstDecode<
RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>,
>,
executable: impl CstDecode<String>, executable: impl CstDecode<String>,
arguments: impl CstDecode<Vec<String>>, arguments: impl CstDecode<Vec<String>>,
working_directory: impl CstDecode<String>, working_directory: impl CstDecode<String>,
@ -191,12 +153,11 @@ fn wire_RsProcess_start_impl(
) { ) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>( FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
flutter_rust_bridge::for_generated::TaskInfo { flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "RsProcess_start", debug_name: "start",
port: Some(port_), port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
}, },
move || { move || {
let api_that = that.cst_decode();
let api_executable = executable.cst_decode(); let api_executable = executable.cst_decode();
let api_arguments = arguments.cst_decode(); let api_arguments = arguments.cst_decode();
let api_working_directory = working_directory.cst_decode(); let api_working_directory = working_directory.cst_decode();
@ -204,10 +165,8 @@ fn wire_RsProcess_start_impl(
move |context| async move { move |context| async move {
transform_result_dco( transform_result_dco(
(move || async move { (move || async move {
let mut api_that = api_that.rust_auto_opaque_decode_ref_mut();
Result::<_, ()>::Ok( Result::<_, ()>::Ok(
crate::api::rs_process::RsProcess::start( crate::api::rs_process::start(
&mut api_that,
api_executable, api_executable,
api_arguments, api_arguments,
api_working_directory, api_working_directory,
@ -222,28 +181,25 @@ fn wire_RsProcess_start_impl(
}, },
) )
} }
fn wire_RsProcess_write_impl( fn wire_write_impl(
port_: flutter_rust_bridge::for_generated::MessagePort, port_: flutter_rust_bridge::for_generated::MessagePort,
that: impl CstDecode< rs_pid: impl CstDecode<u32>,
RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>,
>,
data: impl CstDecode<String>, data: impl CstDecode<String>,
) { ) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>( FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
flutter_rust_bridge::for_generated::TaskInfo { flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "RsProcess_write", debug_name: "write",
port: Some(port_), port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
}, },
move || { move || {
let api_that = that.cst_decode(); let api_rs_pid = rs_pid.cst_decode();
let api_data = data.cst_decode(); let api_data = data.cst_decode();
move |context| async move { move |context| async move {
transform_result_dco( transform_result_dco(
(move || async move { (move || async move {
let mut api_that = api_that.rust_auto_opaque_decode_ref_mut();
Result::<_, ()>::Ok( Result::<_, ()>::Ok(
crate::api::rs_process::RsProcess::write(&mut api_that, api_data).await, crate::api::rs_process::write(&api_rs_pid, api_data).await,
) )
})() })()
.await, .await,
@ -327,12 +283,6 @@ impl CstDecode<u8> for u8 {
self self
} }
} }
impl CstDecode<usize> for usize {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> usize {
self
}
}
impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error { impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@ -340,16 +290,6 @@ impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error {
} }
} }
impl SseDecode for RsProcess {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut inner = <RustOpaqueNom<
flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>,
>>::sse_decode(deserializer);
return inner.rust_auto_opaque_decode_owned();
}
}
impl SseDecode for std::collections::HashMap<String, String> { impl SseDecode for std::collections::HashMap<String, String> {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@ -358,16 +298,6 @@ impl SseDecode for std::collections::HashMap<String, String> {
} }
} }
impl SseDecode
for RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>
{
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut inner = <usize>::sse_decode(deserializer);
return unsafe { decode_rust_opaque_nom(inner) };
}
}
impl SseDecode impl SseDecode
for StreamSink< for StreamSink<
crate::api::rs_process::RsProcessStreamData, crate::api::rs_process::RsProcessStreamData,
@ -491,17 +421,6 @@ impl SseDecode for Option<String> {
} }
} }
impl SseDecode for Option<u32> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
if (<bool>::sse_decode(deserializer)) {
return Some(<u32>::sse_decode(deserializer));
} else {
return None;
}
}
}
impl SseDecode for Option<u64> { impl SseDecode for Option<u64> {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@ -539,9 +458,11 @@ impl SseDecode for crate::api::rs_process::RsProcessStreamData {
let mut var_dataType = let mut var_dataType =
<crate::api::rs_process::RsProcessStreamDataType>::sse_decode(deserializer); <crate::api::rs_process::RsProcessStreamDataType>::sse_decode(deserializer);
let mut var_data = <String>::sse_decode(deserializer); let mut var_data = <String>::sse_decode(deserializer);
let mut var_rsPid = <u32>::sse_decode(deserializer);
return crate::api::rs_process::RsProcessStreamData { return crate::api::rs_process::RsProcessStreamData {
data_type: var_dataType, data_type: var_dataType,
data: var_data, data: var_data,
rs_pid: var_rsPid,
}; };
} }
} }
@ -614,13 +535,6 @@ impl SseDecode for () {
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {} fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {}
} }
impl SseDecode for usize {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
deserializer.cursor.read_u64::<NativeEndian>().unwrap() as _
}
}
impl SseDecode for bool { impl SseDecode for bool {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@ -655,21 +569,6 @@ fn pde_ffi_dispatcher_sync_impl(
// Section: rust2dart // Section: rust2dart
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for FrbWrapper<RsProcess> {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, StdArc<_>>(self.0)
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for FrbWrapper<RsProcess> {}
impl flutter_rust_bridge::IntoIntoDart<FrbWrapper<RsProcess>> for RsProcess {
fn into_into_dart(self) -> FrbWrapper<RsProcess> {
self.into()
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for crate::http_package::MyHttpVersion { impl flutter_rust_bridge::IntoDart for crate::http_package::MyHttpVersion {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
@ -727,6 +626,7 @@ impl flutter_rust_bridge::IntoDart for crate::api::rs_process::RsProcessStreamDa
[ [
self.data_type.into_into_dart().into_dart(), self.data_type.into_into_dart().into_dart(),
self.data.into_into_dart().into_dart(), self.data.into_into_dart().into_dart(),
self.rs_pid.into_into_dart().into_dart(),
] ]
.into_dart() .into_dart()
} }
@ -797,13 +697,6 @@ impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error {
} }
} }
impl SseEncode for RsProcess {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>>::sse_encode(flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, StdArc<_>>(self), serializer);
}
}
impl SseEncode for std::collections::HashMap<String, String> { impl SseEncode for std::collections::HashMap<String, String> {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@ -811,17 +704,6 @@ impl SseEncode for std::collections::HashMap<String, String> {
} }
} }
impl SseEncode
for RustOpaqueNom<flutter_rust_bridge::for_generated::rust_async::RwLock<RsProcess>>
{
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
let (ptr, size) = self.sse_encode_raw();
<usize>::sse_encode(ptr, serializer);
<i32>::sse_encode(size, serializer);
}
}
impl SseEncode impl SseEncode
for StreamSink< for StreamSink<
crate::api::rs_process::RsProcessStreamData, crate::api::rs_process::RsProcessStreamData,
@ -941,16 +823,6 @@ impl SseEncode for Option<String> {
} }
} }
impl SseEncode for Option<u32> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<bool>::sse_encode(self.is_some(), serializer);
if let Some(value) = self {
<u32>::sse_encode(value, serializer);
}
}
}
impl SseEncode for Option<u64> { impl SseEncode for Option<u64> {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@ -984,6 +856,7 @@ impl SseEncode for crate::api::rs_process::RsProcessStreamData {
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<crate::api::rs_process::RsProcessStreamDataType>::sse_encode(self.data_type, serializer); <crate::api::rs_process::RsProcessStreamDataType>::sse_encode(self.data_type, serializer);
<String>::sse_encode(self.data, serializer); <String>::sse_encode(self.data, serializer);
<u32>::sse_encode(self.rs_pid, serializer);
} }
} }
@ -1050,16 +923,6 @@ impl SseEncode for () {
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {} fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {}
} }
impl SseEncode for usize {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
serializer
.cursor
.write_u64::<NativeEndian>(self as _)
.unwrap();
}
}
impl SseEncode for bool { impl SseEncode for bool {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {