[mob][photos] Time rust processing
This commit is contained in:
@@ -58,17 +58,26 @@ class FaceDetectionService extends MlModel {
|
||||
|
||||
final startTime = DateTime.now();
|
||||
|
||||
final result = await processYoloFace(imagePath: imagePath);
|
||||
final (result, timing) = await processYoloFace(imagePath: imagePath);
|
||||
_logger.info("Face detection preprocessing: \n $timing");
|
||||
const scaledSize = Dimensions(width: 640, height: 640);
|
||||
final preprocessingTime = DateTime.now();
|
||||
final preprocessingMs =
|
||||
preprocessingTime.difference(startTime).inMilliseconds;
|
||||
|
||||
final tempTime = DateTime.now();
|
||||
final inputImageList = await resizedToPreprocessed(result);
|
||||
_logger.info(
|
||||
'Face detection remaining dart processing: ${DateTime.now().difference(tempTime).inMilliseconds} ms',
|
||||
);
|
||||
|
||||
// final (inputImageList, scaledSize) = await preprocessImageYoloFace(
|
||||
// image,
|
||||
// rawRgbaBytes,
|
||||
// );
|
||||
final preprocessingTime = DateTime.now();
|
||||
final preprocessingMs =
|
||||
preprocessingTime.difference(startTime).inMilliseconds;
|
||||
// final preprocessingTime = DateTime.now();
|
||||
// final preprocessingMs =
|
||||
// preprocessingTime.difference(startTime).inMilliseconds;
|
||||
|
||||
// Run inference
|
||||
List<List<List<double>>>? nestedResults = [];
|
||||
@@ -89,9 +98,10 @@ class FaceDetectionService extends MlModel {
|
||||
);
|
||||
} catch (e, s) {
|
||||
_logger.severe(
|
||||
'Error while running inference (PlatformPlugin: ${MlModel.usePlatformPlugin})',
|
||||
e,
|
||||
s,);
|
||||
'Error while running inference (PlatformPlugin: ${MlModel.usePlatformPlugin})',
|
||||
e,
|
||||
s,
|
||||
);
|
||||
throw YOLOFaceInterpreterRunException();
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
||||
import 'package:photos/src/rust/frb_generated.dart';
|
||||
|
||||
Future<Uint8List> processYoloFace({required String imagePath}) =>
|
||||
Future<(Uint8List, String)> processYoloFace({required String imagePath}) =>
|
||||
RustLib.instance.api
|
||||
.crateApiImageProcessingProcessYoloFace(imagePath: imagePath);
|
||||
|
||||
@@ -83,7 +83,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
|
||||
}
|
||||
|
||||
abstract class RustLibApi extends BaseApi {
|
||||
Future<Uint8List> crateApiImageProcessingProcessYoloFace(
|
||||
Future<(Uint8List, String)> crateApiImageProcessingProcessYoloFace(
|
||||
{required String imagePath});
|
||||
|
||||
String crateApiSimpleGreet({required String name});
|
||||
@@ -100,17 +100,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
});
|
||||
|
||||
@override
|
||||
Future<Uint8List> crateApiImageProcessingProcessYoloFace(
|
||||
Future<(Uint8List, String)> crateApiImageProcessingProcessYoloFace(
|
||||
{required String imagePath}) {
|
||||
return handler.executeNormal(NormalTask(
|
||||
callFfi: (port_) {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
sse_encode_String(imagePath, serializer);
|
||||
pdeCallFfi(generalizedFrbRustBinding, serializer,
|
||||
funcId: 1, port: port_);
|
||||
final arg0 = cst_encode_String(imagePath);
|
||||
return wire.wire__crate__api__image_processing__process_yolo_face(
|
||||
port_, arg0);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_list_prim_u_8_strict,
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_record_list_prim_u_8_strict_string,
|
||||
decodeErrorData: null,
|
||||
),
|
||||
constMeta: kCrateApiImageProcessingProcessYoloFaceConstMeta,
|
||||
@@ -129,12 +128,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
String crateApiSimpleGreet({required String name}) {
|
||||
return handler.executeSync(SyncTask(
|
||||
callFfi: () {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
sse_encode_String(name, serializer);
|
||||
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 2)!;
|
||||
final arg0 = cst_encode_String(name);
|
||||
return wire.wire__crate__api__simple__greet(arg0);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_String,
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_String,
|
||||
decodeErrorData: null,
|
||||
),
|
||||
constMeta: kCrateApiSimpleGreetConstMeta,
|
||||
@@ -152,12 +150,10 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
Future<void> crateApiSimpleInitApp() {
|
||||
return handler.executeNormal(NormalTask(
|
||||
callFfi: (port_) {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
pdeCallFfi(generalizedFrbRustBinding, serializer,
|
||||
funcId: 3, port: port_);
|
||||
return wire.wire__crate__api__simple__init_app(port_);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_unit,
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_unit,
|
||||
decodeErrorData: null,
|
||||
),
|
||||
constMeta: kCrateApiSimpleInitAppConstMeta,
|
||||
@@ -183,6 +179,20 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return raw as Uint8List;
|
||||
}
|
||||
|
||||
@protected
|
||||
(Uint8List, String) dco_decode_record_list_prim_u_8_strict_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_list_prim_u_8_strict(arr[0]),
|
||||
dco_decode_String(arr[1]),
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
int dco_decode_u_8(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
@@ -209,6 +219,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return deserializer.buffer.getUint8List(len_);
|
||||
}
|
||||
|
||||
@protected
|
||||
(Uint8List, String) sse_decode_record_list_prim_u_8_strict_string(
|
||||
SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
final var_field0 = sse_decode_list_prim_u_8_strict(deserializer);
|
||||
final var_field1 = sse_decode_String(deserializer);
|
||||
return (var_field0, var_field1);
|
||||
}
|
||||
|
||||
@protected
|
||||
int sse_decode_u_8(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -232,6 +251,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return deserializer.buffer.getUint8() != 0;
|
||||
}
|
||||
|
||||
@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_String(String self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -246,6 +277,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
serializer.buffer.putUint8List(self);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_record_list_prim_u_8_strict_string(
|
||||
(Uint8List, String) self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
sse_encode_list_prim_u_8_strict(self.$1, serializer);
|
||||
sse_encode_String(self.$2, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_u_8(int self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
|
||||
// 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/image_processing.dart';
|
||||
import 'api/simple.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi' as ffi;
|
||||
|
||||
import 'frb_generated.dart';
|
||||
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart';
|
||||
import 'package:photos/src/rust/api/image_processing.dart';
|
||||
import 'package:photos/src/rust/api/simple.dart';
|
||||
import 'package:photos/src/rust/frb_generated.dart';
|
||||
|
||||
abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
RustLibApiImplPlatform({
|
||||
@@ -28,6 +27,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
Uint8List dco_decode_list_prim_u_8_strict(dynamic raw);
|
||||
|
||||
@protected
|
||||
(Uint8List, String) dco_decode_record_list_prim_u_8_strict_string(
|
||||
dynamic raw);
|
||||
|
||||
@protected
|
||||
int dco_decode_u_8(dynamic raw);
|
||||
|
||||
@@ -40,6 +43,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
(Uint8List, String) sse_decode_record_list_prim_u_8_strict_string(
|
||||
SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
int sse_decode_u_8(SseDeserializer deserializer);
|
||||
|
||||
@@ -52,6 +59,35 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
bool sse_decode_bool(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_encode_String(String raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
return cst_encode_list_prim_u_8_strict(utf8.encoder.convert(raw));
|
||||
}
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_encode_list_prim_u_8_strict(
|
||||
Uint8List raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
final ans = wire.cst_new_list_prim_u_8_strict(raw.length);
|
||||
ans.ref.ptr.asTypedList(raw.length).setAll(0, raw);
|
||||
return ans;
|
||||
}
|
||||
|
||||
@protected
|
||||
void cst_api_fill_to_wire_record_list_prim_u_8_strict_string(
|
||||
(Uint8List, String) apiObj,
|
||||
wire_cst_record_list_prim_u_8_strict_string wireObj) {
|
||||
wireObj.field0 = cst_encode_list_prim_u_8_strict(apiObj.$1);
|
||||
wireObj.field1 = cst_encode_String(apiObj.$2);
|
||||
}
|
||||
|
||||
@protected
|
||||
int cst_encode_u_8(int raw);
|
||||
|
||||
@protected
|
||||
void cst_encode_unit(void raw);
|
||||
|
||||
@protected
|
||||
void sse_encode_String(String self, SseSerializer serializer);
|
||||
|
||||
@@ -59,6 +95,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
void sse_encode_list_prim_u_8_strict(
|
||||
Uint8List self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_record_list_prim_u_8_strict_string(
|
||||
(Uint8List, String) self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_u_8(int self, SseSerializer serializer);
|
||||
|
||||
@@ -74,6 +114,13 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
|
||||
// Section: wire_class
|
||||
|
||||
// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names
|
||||
// AUTO GENERATED FILE, DO NOT EDIT.
|
||||
//
|
||||
// Generated by `package:ffigen`.
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// generated by flutter_rust_bridge
|
||||
class RustLibWire implements BaseWire {
|
||||
factory RustLibWire.fromExternalLibrary(ExternalLibrary lib) =>
|
||||
RustLibWire(lib.ffiDynamicLibrary);
|
||||
@@ -85,4 +132,122 @@ class RustLibWire implements BaseWire {
|
||||
/// The symbols are looked up in [dynamicLibrary].
|
||||
RustLibWire(ffi.DynamicLibrary dynamicLibrary)
|
||||
: _lookup = dynamicLibrary.lookup;
|
||||
|
||||
/// The symbols are looked up with [lookup].
|
||||
RustLibWire.fromLookup(
|
||||
ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
|
||||
lookup)
|
||||
: _lookup = lookup;
|
||||
|
||||
void store_dart_post_cobject(
|
||||
DartPostCObjectFnType ptr,
|
||||
) {
|
||||
return _store_dart_post_cobject(
|
||||
ptr,
|
||||
);
|
||||
}
|
||||
|
||||
late final _store_dart_post_cobjectPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(DartPostCObjectFnType)>>(
|
||||
'store_dart_post_cobject');
|
||||
late final _store_dart_post_cobject = _store_dart_post_cobjectPtr
|
||||
.asFunction<void Function(DartPostCObjectFnType)>();
|
||||
|
||||
void wire__crate__api__image_processing__process_yolo_face(
|
||||
int port_,
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> image_path,
|
||||
) {
|
||||
return _wire__crate__api__image_processing__process_yolo_face(
|
||||
port_,
|
||||
image_path,
|
||||
);
|
||||
}
|
||||
|
||||
late final _wire__crate__api__image_processing__process_yolo_facePtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(
|
||||
ffi.Int64, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
|
||||
'frbgen_photos_wire__crate__api__image_processing__process_yolo_face');
|
||||
late final _wire__crate__api__image_processing__process_yolo_face =
|
||||
_wire__crate__api__image_processing__process_yolo_facePtr.asFunction<
|
||||
void Function(int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
|
||||
|
||||
WireSyncRust2DartDco wire__crate__api__simple__greet(
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> name,
|
||||
) {
|
||||
return _wire__crate__api__simple__greet(
|
||||
name,
|
||||
);
|
||||
}
|
||||
|
||||
late final _wire__crate__api__simple__greetPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
WireSyncRust2DartDco Function(
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
|
||||
'frbgen_photos_wire__crate__api__simple__greet');
|
||||
late final _wire__crate__api__simple__greet =
|
||||
_wire__crate__api__simple__greetPtr.asFunction<
|
||||
WireSyncRust2DartDco Function(
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
|
||||
|
||||
void wire__crate__api__simple__init_app(
|
||||
int port_,
|
||||
) {
|
||||
return _wire__crate__api__simple__init_app(
|
||||
port_,
|
||||
);
|
||||
}
|
||||
|
||||
late final _wire__crate__api__simple__init_appPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64)>>(
|
||||
'frbgen_photos_wire__crate__api__simple__init_app');
|
||||
late final _wire__crate__api__simple__init_app =
|
||||
_wire__crate__api__simple__init_appPtr.asFunction<void Function(int)>();
|
||||
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_new_list_prim_u_8_strict(
|
||||
int len,
|
||||
) {
|
||||
return _cst_new_list_prim_u_8_strict(
|
||||
len,
|
||||
);
|
||||
}
|
||||
|
||||
late final _cst_new_list_prim_u_8_strictPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> Function(
|
||||
ffi.Int32)>>('frbgen_photos_cst_new_list_prim_u_8_strict');
|
||||
late final _cst_new_list_prim_u_8_strict = _cst_new_list_prim_u_8_strictPtr
|
||||
.asFunction<ffi.Pointer<wire_cst_list_prim_u_8_strict> Function(int)>();
|
||||
|
||||
int dummy_method_to_enforce_bundling() {
|
||||
return _dummy_method_to_enforce_bundling();
|
||||
}
|
||||
|
||||
late final _dummy_method_to_enforce_bundlingPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Int64 Function()>>(
|
||||
'dummy_method_to_enforce_bundling');
|
||||
late final _dummy_method_to_enforce_bundling =
|
||||
_dummy_method_to_enforce_bundlingPtr.asFunction<int Function()>();
|
||||
}
|
||||
|
||||
typedef DartPostCObjectFnType
|
||||
= ffi.Pointer<ffi.NativeFunction<DartPostCObjectFnTypeFunction>>;
|
||||
typedef DartPostCObjectFnTypeFunction = ffi.Bool Function(
|
||||
DartPort port_id, ffi.Pointer<ffi.Void> message);
|
||||
typedef DartDartPostCObjectFnTypeFunction = bool Function(
|
||||
DartDartPort port_id, ffi.Pointer<ffi.Void> message);
|
||||
typedef DartPort = ffi.Int64;
|
||||
typedef DartDartPort = int;
|
||||
|
||||
final class wire_cst_list_prim_u_8_strict extends ffi.Struct {
|
||||
external ffi.Pointer<ffi.Uint8> ptr;
|
||||
|
||||
@ffi.Int32()
|
||||
external int len;
|
||||
}
|
||||
|
||||
final class wire_cst_record_list_prim_u_8_strict_string extends ffi.Struct {
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> field0;
|
||||
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> field1;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,41 @@
|
||||
use resize::{px::RGB, Pixel::RGB8, Type::Lanczos3};
|
||||
use rgb::FromSlice;
|
||||
|
||||
pub fn process_yolo_face(image_path: &str) -> Vec<u8> {
|
||||
pub fn process_yolo_face(image_path: &str) -> (Vec<u8>, String) {
|
||||
let mut timing = String::new();
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
// Load the image
|
||||
let img = image::open(image_path).expect("Failed to open image");
|
||||
let load_time = start.elapsed().as_millis();
|
||||
timing.push_str(&format!("Load time: {}ms\n", load_time));
|
||||
|
||||
// Get dimensions
|
||||
let (width, height) = (img.width() as usize, img.height() as usize);
|
||||
let (new_width, new_height) = (640, 640);
|
||||
let dimensions_time = start.elapsed().as_millis() - load_time;
|
||||
timing.push_str(&format!("Dimensions time: {}ms\n", dimensions_time));
|
||||
|
||||
// Convert image to RGB8
|
||||
let rgb_img = img.to_rgb8();
|
||||
let convert_time = start.elapsed().as_millis() - dimensions_time;
|
||||
timing.push_str(&format!("Convert time: {}ms\n", convert_time));
|
||||
let rgb_vec = rgb_img.to_vec();
|
||||
let rgb_vec_time = start.elapsed().as_millis() - convert_time;
|
||||
timing.push_str(&format!("RGB Vec time: {}ms\n", rgb_vec_time));
|
||||
|
||||
// Create resizer
|
||||
let mut resizer = resize::new(width, height, new_width, new_height, RGB8, Lanczos3).unwrap();
|
||||
|
||||
// Create buffer for resized image
|
||||
let mut dst = vec![RGB::new(0, 0, 0); new_width * new_height];
|
||||
let buffer_time = start.elapsed().as_millis() - rgb_vec_time;
|
||||
timing.push_str(&format!("Buffer time: {}ms\n", buffer_time));
|
||||
|
||||
// Create ImageBuffer from resized data
|
||||
resizer.resize(rgb_vec.as_rgb(), &mut dst).unwrap();
|
||||
let resize_time = start.elapsed().as_millis() - buffer_time;
|
||||
timing.push_str(&format!("Resize time: {}ms\n", resize_time));
|
||||
|
||||
// Return dst as a Vec<u8>
|
||||
let mut result = Vec::new();
|
||||
@@ -29,5 +44,7 @@ pub fn process_yolo_face(image_path: &str) -> Vec<u8> {
|
||||
result.push(pixel.g);
|
||||
result.push(pixel.b);
|
||||
}
|
||||
result
|
||||
let result_time = start.elapsed().as_millis() - resize_time;
|
||||
timing.push_str(&format!("Result time: {}ms\n", result_time));
|
||||
(result, timing)
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ use flutter_rust_bridge::{Handler, IntoIntoDart};
|
||||
// Section: boilerplate
|
||||
|
||||
flutter_rust_bridge::frb_generated_boilerplate!(
|
||||
default_stream_sink_codec = SseCodec,
|
||||
default_rust_opaque = RustOpaqueMoi,
|
||||
default_rust_auto_opaque = RustAutoOpaqueMoi,
|
||||
default_stream_sink_codec = DcoCodec,
|
||||
default_rust_opaque = RustOpaqueNom,
|
||||
default_rust_auto_opaque = RustAutoOpaqueNom,
|
||||
);
|
||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.5.1";
|
||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1774582320;
|
||||
@@ -47,30 +47,18 @@ flutter_rust_bridge::frb_generated_default_handler!();
|
||||
|
||||
fn wire__crate__api__image_processing__process_yolo_face_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
|
||||
rust_vec_len_: i32,
|
||||
data_len_: i32,
|
||||
image_path: impl CstDecode<String>,
|
||||
) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::DcoCodec, _, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
debug_name: "process_yolo_face",
|
||||
port: Some(port_),
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||
},
|
||||
move || {
|
||||
let message = unsafe {
|
||||
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
|
||||
ptr_,
|
||||
rust_vec_len_,
|
||||
data_len_,
|
||||
)
|
||||
};
|
||||
let mut deserializer =
|
||||
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
|
||||
let api_image_path = <String>::sse_decode(&mut deserializer);
|
||||
deserializer.end();
|
||||
let api_image_path = image_path.cst_decode();
|
||||
move |context| {
|
||||
transform_result_sse::<_, ()>((move || {
|
||||
transform_result_dco::<_, _, ()>((move || {
|
||||
let output_ok = Result::<_, ()>::Ok(
|
||||
crate::api::image_processing::process_yolo_face(&api_image_path),
|
||||
)?;
|
||||
@@ -81,60 +69,33 @@ fn wire__crate__api__image_processing__process_yolo_face_impl(
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__simple__greet_impl(
|
||||
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
|
||||
rust_vec_len_: i32,
|
||||
data_len_: i32,
|
||||
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::<flutter_rust_bridge::for_generated::SseCodec, _>(
|
||||
name: impl CstDecode<String>,
|
||||
) -> 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: "greet",
|
||||
port: None,
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync,
|
||||
},
|
||||
move || {
|
||||
let message = unsafe {
|
||||
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
|
||||
ptr_,
|
||||
rust_vec_len_,
|
||||
data_len_,
|
||||
)
|
||||
};
|
||||
let mut deserializer =
|
||||
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
|
||||
let api_name = <String>::sse_decode(&mut deserializer);
|
||||
deserializer.end();
|
||||
transform_result_sse::<_, ()>((move || {
|
||||
let api_name = name.cst_decode();
|
||||
transform_result_dco::<_, _, ()>((move || {
|
||||
let output_ok = Result::<_, ()>::Ok(crate::api::simple::greet(api_name))?;
|
||||
Ok(output_ok)
|
||||
})())
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__simple__init_app_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
|
||||
rust_vec_len_: i32,
|
||||
data_len_: i32,
|
||||
) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
|
||||
fn wire__crate__api__simple__init_app_impl(port_: flutter_rust_bridge::for_generated::MessagePort) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::DcoCodec, _, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
debug_name: "init_app",
|
||||
port: Some(port_),
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||
},
|
||||
move || {
|
||||
let message = unsafe {
|
||||
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
|
||||
ptr_,
|
||||
rust_vec_len_,
|
||||
data_len_,
|
||||
)
|
||||
};
|
||||
let mut deserializer =
|
||||
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
|
||||
deserializer.end();
|
||||
move |context| {
|
||||
transform_result_sse::<_, ()>((move || {
|
||||
transform_result_dco::<_, _, ()>((move || {
|
||||
let output_ok = Result::<_, ()>::Ok({
|
||||
crate::api::simple::init_app();
|
||||
})?;
|
||||
@@ -147,6 +108,12 @@ fn wire__crate__api__simple__init_app_impl(
|
||||
|
||||
// Section: dart2rust
|
||||
|
||||
impl CstDecode<u8> for u8 {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> u8 {
|
||||
self
|
||||
}
|
||||
}
|
||||
impl SseDecode for String {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
@@ -167,6 +134,15 @@ impl SseDecode for Vec<u8> {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for (Vec<u8>, String) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
let mut var_field0 = <Vec<u8>>::sse_decode(deserializer);
|
||||
let mut var_field1 = <String>::sse_decode(deserializer);
|
||||
return (var_field0, var_field1);
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for u8 {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
@@ -202,13 +178,6 @@ fn pde_ffi_dispatcher_primary_impl(
|
||||
) {
|
||||
// Codec=Pde (Serialization + dispatch), see doc to use other codecs
|
||||
match func_id {
|
||||
1 => wire__crate__api__image_processing__process_yolo_face_impl(
|
||||
port,
|
||||
ptr,
|
||||
rust_vec_len,
|
||||
data_len,
|
||||
),
|
||||
3 => wire__crate__api__simple__init_app_impl(port, ptr, rust_vec_len, data_len),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -221,7 +190,6 @@ fn pde_ffi_dispatcher_sync_impl(
|
||||
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse {
|
||||
// Codec=Pde (Serialization + dispatch), see doc to use other codecs
|
||||
match func_id {
|
||||
2 => wire__crate__api__simple__greet_impl(ptr, rust_vec_len, data_len),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -245,6 +213,14 @@ impl SseEncode for Vec<u8> {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for (Vec<u8>, String) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
<Vec<u8>>::sse_encode(self.0, serializer);
|
||||
<String>::sse_encode(self.1, serializer);
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for u8 {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
@@ -288,30 +264,88 @@ mod io {
|
||||
// Section: boilerplate
|
||||
|
||||
flutter_rust_bridge::frb_generated_boilerplate_io!();
|
||||
|
||||
// Section: dart2rust
|
||||
|
||||
impl CstDecode<String> for *mut wire_cst_list_prim_u_8_strict {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> String {
|
||||
let vec: Vec<u8> = self.cst_decode();
|
||||
String::from_utf8(vec).unwrap()
|
||||
}
|
||||
}
|
||||
impl CstDecode<Vec<u8>> for *mut wire_cst_list_prim_u_8_strict {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> Vec<u8> {
|
||||
unsafe {
|
||||
let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self);
|
||||
flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl CstDecode<(Vec<u8>, String)> for wire_cst_record_list_prim_u_8_strict_string {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> (Vec<u8>, String) {
|
||||
(self.field0.cst_decode(), self.field1.cst_decode())
|
||||
}
|
||||
}
|
||||
impl NewWithNullPtr for wire_cst_record_list_prim_u_8_strict_string {
|
||||
fn new_with_null_ptr() -> Self {
|
||||
Self {
|
||||
field0: core::ptr::null_mut(),
|
||||
field1: core::ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Default for wire_cst_record_list_prim_u_8_strict_string {
|
||||
fn default() -> Self {
|
||||
Self::new_with_null_ptr()
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn frbgen_photos_wire__crate__api__image_processing__process_yolo_face(
|
||||
port_: i64,
|
||||
image_path: *mut wire_cst_list_prim_u_8_strict,
|
||||
) {
|
||||
wire__crate__api__image_processing__process_yolo_face_impl(port_, image_path)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn frbgen_photos_wire__crate__api__simple__greet(
|
||||
name: *mut wire_cst_list_prim_u_8_strict,
|
||||
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
|
||||
wire__crate__api__simple__greet_impl(name)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn frbgen_photos_wire__crate__api__simple__init_app(port_: i64) {
|
||||
wire__crate__api__simple__init_app_impl(port_)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn frbgen_photos_cst_new_list_prim_u_8_strict(
|
||||
len: i32,
|
||||
) -> *mut wire_cst_list_prim_u_8_strict {
|
||||
let ans = wire_cst_list_prim_u_8_strict {
|
||||
ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr(Default::default(), len),
|
||||
len,
|
||||
};
|
||||
flutter_rust_bridge::for_generated::new_leak_box_ptr(ans)
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct wire_cst_list_prim_u_8_strict {
|
||||
ptr: *mut u8,
|
||||
len: i32,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct wire_cst_record_list_prim_u_8_strict_string {
|
||||
field0: *mut wire_cst_list_prim_u_8_strict,
|
||||
field1: *mut wire_cst_list_prim_u_8_strict,
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
pub use io::*;
|
||||
|
||||
/// cbindgen:ignore
|
||||
#[cfg(target_family = "wasm")]
|
||||
mod web {
|
||||
// This file is automatically generated, so please do not edit it.
|
||||
// @generated by `flutter_rust_bridge`@ 2.5.1.
|
||||
|
||||
// Section: imports
|
||||
|
||||
use super::*;
|
||||
use flutter_rust_bridge::for_generated::byteorder::{
|
||||
NativeEndian, ReadBytesExt, WriteBytesExt,
|
||||
};
|
||||
use flutter_rust_bridge::for_generated::wasm_bindgen;
|
||||
use flutter_rust_bridge::for_generated::wasm_bindgen::prelude::*;
|
||||
use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable};
|
||||
use flutter_rust_bridge::{Handler, IntoIntoDart};
|
||||
|
||||
// Section: boilerplate
|
||||
|
||||
flutter_rust_bridge::frb_generated_boilerplate_web!();
|
||||
}
|
||||
#[cfg(target_family = "wasm")]
|
||||
pub use web::*;
|
||||
|
||||
Reference in New Issue
Block a user