mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-02-06 15:10:20 +00:00
feat: Migrate PowerShell calls to Rust implementation
This commit is contained in:
@@ -71,7 +71,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
|
||||
String get codegenVersion => '2.11.1';
|
||||
|
||||
@override
|
||||
int get rustContentHash => -1082688871;
|
||||
int get rustContentHash => 1317751362;
|
||||
|
||||
static const kDefaultExternalLibraryLoaderConfig =
|
||||
ExternalLibraryLoaderConfig(
|
||||
@@ -102,6 +102,10 @@ abstract class RustLibApi extends BaseApi {
|
||||
String? pathSuffix,
|
||||
});
|
||||
|
||||
Future<String> crateApiWin32ApiGetGpuInfoFromRegistry();
|
||||
|
||||
Future<int> crateApiWin32ApiGetNumberOfLogicalProcessors();
|
||||
|
||||
Future<List<ProcessInfo>> crateApiWin32ApiGetProcessListByName({
|
||||
required String processName,
|
||||
});
|
||||
@@ -114,6 +118,10 @@ abstract class RustLibApi extends BaseApi {
|
||||
required String asarPath,
|
||||
});
|
||||
|
||||
Future<SystemInfo> crateApiWin32ApiGetSystemInfo();
|
||||
|
||||
Future<BigInt> crateApiWin32ApiGetSystemMemorySizeGb();
|
||||
|
||||
Future<void> crateApiOrtApiLoadTranslationModel({
|
||||
required String modelPath,
|
||||
required String modelKey,
|
||||
@@ -121,6 +129,11 @@ abstract class RustLibApi extends BaseApi {
|
||||
required bool useXnnpack,
|
||||
});
|
||||
|
||||
Future<void> crateApiWin32ApiOpenDirWithExplorer({
|
||||
required String path,
|
||||
required bool isFile,
|
||||
});
|
||||
|
||||
Future<void> crateApiUnp4KApiP4KClose();
|
||||
|
||||
Future<void> crateApiUnp4KApiP4KExtractToDisk({
|
||||
@@ -138,6 +151,8 @@ abstract class RustLibApi extends BaseApi {
|
||||
|
||||
Future<void> crateApiUnp4KApiP4KOpen({required String p4KPath});
|
||||
|
||||
Future<String> crateApiWin32ApiResolveShortcut({required String lnkPath});
|
||||
|
||||
Future<void> crateApiAsarApiRsiLauncherAsarDataWriteMainJs({
|
||||
required RsiLauncherAsarData that,
|
||||
required List<int> content,
|
||||
@@ -402,6 +417,59 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
argNames: ["urls", "pathSuffix"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<String> crateApiWin32ApiGetGpuInfoFromRegistry() {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
return wire.wire__crate__api__win32_api__get_gpu_info_from_registry(
|
||||
port_,
|
||||
);
|
||||
},
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_String,
|
||||
decodeErrorData: dco_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiWin32ApiGetGpuInfoFromRegistryConstMeta,
|
||||
argValues: [],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiWin32ApiGetGpuInfoFromRegistryConstMeta =>
|
||||
const TaskConstMeta(
|
||||
debugName: "get_gpu_info_from_registry",
|
||||
argNames: [],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<int> crateApiWin32ApiGetNumberOfLogicalProcessors() {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
return wire
|
||||
.wire__crate__api__win32_api__get_number_of_logical_processors(
|
||||
port_,
|
||||
);
|
||||
},
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_u_32,
|
||||
decodeErrorData: dco_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiWin32ApiGetNumberOfLogicalProcessorsConstMeta,
|
||||
argValues: [],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiWin32ApiGetNumberOfLogicalProcessorsConstMeta =>
|
||||
const TaskConstMeta(
|
||||
debugName: "get_number_of_logical_processors",
|
||||
argNames: [],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<List<ProcessInfo>> crateApiWin32ApiGetProcessListByName({
|
||||
required String processName,
|
||||
@@ -492,6 +560,50 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
argNames: ["asarPath"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<SystemInfo> crateApiWin32ApiGetSystemInfo() {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
return wire.wire__crate__api__win32_api__get_system_info(port_);
|
||||
},
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_system_info,
|
||||
decodeErrorData: dco_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiWin32ApiGetSystemInfoConstMeta,
|
||||
argValues: [],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiWin32ApiGetSystemInfoConstMeta =>
|
||||
const TaskConstMeta(debugName: "get_system_info", argNames: []);
|
||||
|
||||
@override
|
||||
Future<BigInt> crateApiWin32ApiGetSystemMemorySizeGb() {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
return wire.wire__crate__api__win32_api__get_system_memory_size_gb(
|
||||
port_,
|
||||
);
|
||||
},
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_u_64,
|
||||
decodeErrorData: dco_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiWin32ApiGetSystemMemorySizeGbConstMeta,
|
||||
argValues: [],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiWin32ApiGetSystemMemorySizeGbConstMeta =>
|
||||
const TaskConstMeta(debugName: "get_system_memory_size_gb", argNames: []);
|
||||
|
||||
@override
|
||||
Future<void> crateApiOrtApiLoadTranslationModel({
|
||||
required String modelPath,
|
||||
@@ -531,6 +643,39 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
argNames: ["modelPath", "modelKey", "quantizationSuffix", "useXnnpack"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> crateApiWin32ApiOpenDirWithExplorer({
|
||||
required String path,
|
||||
required bool isFile,
|
||||
}) {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
var arg0 = cst_encode_String(path);
|
||||
var arg1 = cst_encode_bool(isFile);
|
||||
return wire.wire__crate__api__win32_api__open_dir_with_explorer(
|
||||
port_,
|
||||
arg0,
|
||||
arg1,
|
||||
);
|
||||
},
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_unit,
|
||||
decodeErrorData: dco_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiWin32ApiOpenDirWithExplorerConstMeta,
|
||||
argValues: [path, isFile],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiWin32ApiOpenDirWithExplorerConstMeta =>
|
||||
const TaskConstMeta(
|
||||
debugName: "open_dir_with_explorer",
|
||||
argNames: ["path", "isFile"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> crateApiUnp4KApiP4KClose() {
|
||||
return handler.executeNormal(
|
||||
@@ -679,6 +824,31 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
TaskConstMeta get kCrateApiUnp4KApiP4KOpenConstMeta =>
|
||||
const TaskConstMeta(debugName: "p4k_open", argNames: ["p4KPath"]);
|
||||
|
||||
@override
|
||||
Future<String> crateApiWin32ApiResolveShortcut({required String lnkPath}) {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
var arg0 = cst_encode_String(lnkPath);
|
||||
return wire.wire__crate__api__win32_api__resolve_shortcut(
|
||||
port_,
|
||||
arg0,
|
||||
);
|
||||
},
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_String,
|
||||
decodeErrorData: dco_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiWin32ApiResolveShortcutConstMeta,
|
||||
argValues: [lnkPath],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiWin32ApiResolveShortcutConstMeta =>
|
||||
const TaskConstMeta(debugName: "resolve_shortcut", argNames: ["lnkPath"]);
|
||||
|
||||
@override
|
||||
Future<void> crateApiAsarApiRsiLauncherAsarDataWriteMainJs({
|
||||
required RsiLauncherAsarData that,
|
||||
@@ -1667,6 +1837,20 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
SystemInfo dco_decode_system_info(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 4)
|
||||
throw Exception('unexpected arr length: expect 4 but see ${arr.length}');
|
||||
return SystemInfo(
|
||||
osName: dco_decode_String(arr[0]),
|
||||
cpuName: dco_decode_String(arr[1]),
|
||||
gpuInfo: dco_decode_String(arr[2]),
|
||||
diskInfo: dco_decode_String(arr[3]),
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
int dco_decode_u_16(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
@@ -2081,6 +2265,21 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
SystemInfo sse_decode_system_info(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
var var_osName = sse_decode_String(deserializer);
|
||||
var var_cpuName = sse_decode_String(deserializer);
|
||||
var var_gpuInfo = sse_decode_String(deserializer);
|
||||
var var_diskInfo = sse_decode_String(deserializer);
|
||||
return SystemInfo(
|
||||
osName: var_osName,
|
||||
cpuName: var_cpuName,
|
||||
gpuInfo: var_gpuInfo,
|
||||
diskInfo: var_diskInfo,
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
int sse_decode_u_16(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -2556,6 +2755,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_opt_list_prim_u_8_strict(self.data, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_system_info(SystemInfo self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
sse_encode_String(self.osName, serializer);
|
||||
sse_encode_String(self.cpuName, serializer);
|
||||
sse_encode_String(self.gpuInfo, serializer);
|
||||
sse_encode_String(self.diskInfo, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_u_16(int self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
|
||||
Reference in New Issue
Block a user