From 85c60913d507cae34303ad8baf3cc9e5765fd1aa Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Fri, 25 Aug 2023 16:35:27 -0700 Subject: [PATCH] add drop code for txconf --- mobile/lib/bridge_definitions.dart | 4 ++ mobile/lib/bridge_generated.dart | 57 +++++++++++++++++++----- mobile/lib/main.dart | 1 + mobile/native/src/api.rs | 2 + mobile/native/src/bridge_generated.io.rs | 5 +++ mobile/native/src/bridge_generated.rs | 13 ++++++ 6 files changed, 71 insertions(+), 11 deletions(-) diff --git a/mobile/lib/bridge_definitions.dart b/mobile/lib/bridge_definitions.dart index d762a39..1441652 100644 --- a/mobile/lib/bridge_definitions.dart +++ b/mobile/lib/bridge_definitions.dart @@ -13,6 +13,10 @@ abstract class Native { FlutterRustBridgeTaskConstMeta get kGetTxConfigConstMeta; + Future dropTxConfig({required TxConfig txc, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kDropTxConfigConstMeta; + Future decodePackets({required List packets, required TxConfig txconf, dynamic hint}); FlutterRustBridgeTaskConstMeta get kDecodePacketsConstMeta; diff --git a/mobile/lib/bridge_generated.dart b/mobile/lib/bridge_generated.dart index 9ab4f8b..4e49648 100644 --- a/mobile/lib/bridge_generated.dart +++ b/mobile/lib/bridge_generated.dart @@ -40,6 +40,22 @@ class NativeImpl implements Native { argNames: ["bytes"], ); + Future dropTxConfig({required TxConfig txc, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_tx_config(txc); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_drop_tx_config(port_, arg0), + parseSuccessData: _wire2api_unit, + constMeta: kDropTxConfigConstMeta, + argValues: [txc], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kDropTxConfigConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "drop_tx_config", + argNames: ["txc"], + ); + Future decodePackets({required List packets, required TxConfig txconf, dynamic hint}) { var arg0 = _platform.api2wire_list_raptor_packet(packets); var arg1 = _platform.api2wire_box_autoadd_tx_config(txconf); @@ -108,6 +124,10 @@ class NativeImpl implements Native { Uint8List _wire2api_uint_8_list(dynamic raw) { return raw as Uint8List; } + + void _wire2api_unit(dynamic raw) { + return; + } } // Section: api2wire @@ -279,6 +299,21 @@ class NativeWire implements FlutterRustBridgeWireBase { late final _wire_get_tx_config = _wire_get_tx_configPtr.asFunction)>(); + void wire_drop_tx_config( + int port_, + ffi.Pointer _txc, + ) { + return _wire_drop_tx_config( + port_, + _txc, + ); + } + + late final _wire_drop_tx_configPtr = + _lookup)>>('wire_drop_tx_config'); + late final _wire_drop_tx_config = + _wire_drop_tx_configPtr.asFunction)>(); + void wire_decode_packets( int port_, ffi.Pointer packets, @@ -354,17 +389,6 @@ final class wire_uint_8_list extends ffi.Struct { external int len; } -final class wire_RaptorPacket extends ffi.Struct { - external ffi.Pointer field0; -} - -final class wire_list_raptor_packet extends ffi.Struct { - external ffi.Pointer ptr; - - @ffi.Int32() - external int len; -} - final class wire_TxConfig extends ffi.Struct { @ffi.Uint64() external int len; @@ -377,6 +401,17 @@ final class wire_TxConfig extends ffi.Struct { external ffi.Pointer filename; } +final class wire_RaptorPacket extends ffi.Struct { + external ffi.Pointer field0; +} + +final class wire_list_raptor_packet extends ffi.Struct { + external ffi.Pointer ptr; + + @ffi.Int32() + external int len; +} + typedef DartPostCObjectFnType = ffi.Pointer message)>>; typedef DartPort = ffi.Int64; diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart index 4bcb396..fb19e1a 100644 --- a/mobile/lib/main.dart +++ b/mobile/lib/main.dart @@ -122,6 +122,7 @@ class _MyHomePageState extends State { { var txconf = await api.getTxConfig(bytes: dbytes); if (txconf != null || barcode.rawValue != null) { + await api.dropTxConfig(txc: txconf!); continue; } final packet = RaptorPacket(field0: dbytes); diff --git a/mobile/native/src/api.rs b/mobile/native/src/api.rs index 08484ce..230538e 100644 --- a/mobile/native/src/api.rs +++ b/mobile/native/src/api.rs @@ -31,6 +31,8 @@ pub fn get_tx_config(bytes: Vec) -> Option { } } +pub fn drop_tx_config(_txc: TxConfig) {} + pub fn decode_packets(packets: Vec, txconf: TxConfig) -> Option> { let conf = ObjectTransmissionInformation::with_defaults(txconf.len, txconf.mtu); let mut decoder = Decoder::new(conf); diff --git a/mobile/native/src/bridge_generated.io.rs b/mobile/native/src/bridge_generated.io.rs index 94e19c9..72b28e3 100644 --- a/mobile/native/src/bridge_generated.io.rs +++ b/mobile/native/src/bridge_generated.io.rs @@ -6,6 +6,11 @@ pub extern "C" fn wire_get_tx_config(port_: i64, bytes: *mut wire_uint_8_list) { wire_get_tx_config_impl(port_, bytes) } +#[no_mangle] +pub extern "C" fn wire_drop_tx_config(port_: i64, _txc: *mut wire_TxConfig) { + wire_drop_tx_config_impl(port_, _txc) +} + #[no_mangle] pub extern "C" fn wire_decode_packets( port_: i64, diff --git a/mobile/native/src/bridge_generated.rs b/mobile/native/src/bridge_generated.rs index 46fc436..f2501f4 100644 --- a/mobile/native/src/bridge_generated.rs +++ b/mobile/native/src/bridge_generated.rs @@ -35,6 +35,19 @@ fn wire_get_tx_config_impl(port_: MessagePort, bytes: impl Wire2Api> + U }, ) } +fn wire_drop_tx_config_impl(port_: MessagePort, _txc: impl Wire2Api + UnwindSafe) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, ()>( + WrapInfo { + debug_name: "drop_tx_config", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api__txc = _txc.wire2api(); + move |task_callback| Ok(drop_tx_config(api__txc)) + }, + ) +} fn wire_decode_packets_impl( port_: MessagePort, packets: impl Wire2Api> + UnwindSafe,