add drop code for txconf

This commit is contained in:
Joe Ardent 2023-08-25 16:35:27 -07:00
parent 69ae823e68
commit 85c60913d5
6 changed files with 71 additions and 11 deletions

View file

@ -13,6 +13,10 @@ abstract class Native {
FlutterRustBridgeTaskConstMeta get kGetTxConfigConstMeta; FlutterRustBridgeTaskConstMeta get kGetTxConfigConstMeta;
Future<void> dropTxConfig({required TxConfig txc, dynamic hint});
FlutterRustBridgeTaskConstMeta get kDropTxConfigConstMeta;
Future<Uint8List?> decodePackets({required List<RaptorPacket> packets, required TxConfig txconf, dynamic hint}); Future<Uint8List?> decodePackets({required List<RaptorPacket> packets, required TxConfig txconf, dynamic hint});
FlutterRustBridgeTaskConstMeta get kDecodePacketsConstMeta; FlutterRustBridgeTaskConstMeta get kDecodePacketsConstMeta;

View file

@ -40,6 +40,22 @@ class NativeImpl implements Native {
argNames: ["bytes"], argNames: ["bytes"],
); );
Future<void> 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<Uint8List?> decodePackets({required List<RaptorPacket> packets, required TxConfig txconf, dynamic hint}) { Future<Uint8List?> decodePackets({required List<RaptorPacket> packets, required TxConfig txconf, dynamic hint}) {
var arg0 = _platform.api2wire_list_raptor_packet(packets); var arg0 = _platform.api2wire_list_raptor_packet(packets);
var arg1 = _platform.api2wire_box_autoadd_tx_config(txconf); var arg1 = _platform.api2wire_box_autoadd_tx_config(txconf);
@ -108,6 +124,10 @@ class NativeImpl implements Native {
Uint8List _wire2api_uint_8_list(dynamic raw) { Uint8List _wire2api_uint_8_list(dynamic raw) {
return raw as Uint8List; return raw as Uint8List;
} }
void _wire2api_unit(dynamic raw) {
return;
}
} }
// Section: api2wire // Section: api2wire
@ -279,6 +299,21 @@ class NativeWire implements FlutterRustBridgeWireBase {
late final _wire_get_tx_config = late final _wire_get_tx_config =
_wire_get_tx_configPtr.asFunction<void Function(int, ffi.Pointer<wire_uint_8_list>)>(); _wire_get_tx_configPtr.asFunction<void Function(int, ffi.Pointer<wire_uint_8_list>)>();
void wire_drop_tx_config(
int port_,
ffi.Pointer<wire_TxConfig> _txc,
) {
return _wire_drop_tx_config(
port_,
_txc,
);
}
late final _wire_drop_tx_configPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.Pointer<wire_TxConfig>)>>('wire_drop_tx_config');
late final _wire_drop_tx_config =
_wire_drop_tx_configPtr.asFunction<void Function(int, ffi.Pointer<wire_TxConfig>)>();
void wire_decode_packets( void wire_decode_packets(
int port_, int port_,
ffi.Pointer<wire_list_raptor_packet> packets, ffi.Pointer<wire_list_raptor_packet> packets,
@ -354,17 +389,6 @@ final class wire_uint_8_list extends ffi.Struct {
external int len; external int len;
} }
final class wire_RaptorPacket extends ffi.Struct {
external ffi.Pointer<wire_uint_8_list> field0;
}
final class wire_list_raptor_packet extends ffi.Struct {
external ffi.Pointer<wire_RaptorPacket> ptr;
@ffi.Int32()
external int len;
}
final class wire_TxConfig extends ffi.Struct { final class wire_TxConfig extends ffi.Struct {
@ffi.Uint64() @ffi.Uint64()
external int len; external int len;
@ -377,6 +401,17 @@ final class wire_TxConfig extends ffi.Struct {
external ffi.Pointer<wire_uint_8_list> filename; external ffi.Pointer<wire_uint_8_list> filename;
} }
final class wire_RaptorPacket extends ffi.Struct {
external ffi.Pointer<wire_uint_8_list> field0;
}
final class wire_list_raptor_packet extends ffi.Struct {
external ffi.Pointer<wire_RaptorPacket> ptr;
@ffi.Int32()
external int len;
}
typedef DartPostCObjectFnType typedef DartPostCObjectFnType
= ffi.Pointer<ffi.NativeFunction<ffi.Bool Function(DartPort port_id, ffi.Pointer<ffi.Void> message)>>; = ffi.Pointer<ffi.NativeFunction<ffi.Bool Function(DartPort port_id, ffi.Pointer<ffi.Void> message)>>;
typedef DartPort = ffi.Int64; typedef DartPort = ffi.Int64;

View file

@ -122,6 +122,7 @@ class _MyHomePageState extends State<MyHomePage> {
{ {
var txconf = await api.getTxConfig(bytes: dbytes); var txconf = await api.getTxConfig(bytes: dbytes);
if (txconf != null || barcode.rawValue != null) { if (txconf != null || barcode.rawValue != null) {
await api.dropTxConfig(txc: txconf!);
continue; continue;
} }
final packet = RaptorPacket(field0: dbytes); final packet = RaptorPacket(field0: dbytes);

View file

@ -31,6 +31,8 @@ pub fn get_tx_config(bytes: Vec<u8>) -> Option<TxConfig> {
} }
} }
pub fn drop_tx_config(_txc: TxConfig) {}
pub fn decode_packets(packets: Vec<RaptorPacket>, txconf: TxConfig) -> Option<Vec<u8>> { pub fn decode_packets(packets: Vec<RaptorPacket>, txconf: TxConfig) -> Option<Vec<u8>> {
let conf = ObjectTransmissionInformation::with_defaults(txconf.len, txconf.mtu); let conf = ObjectTransmissionInformation::with_defaults(txconf.len, txconf.mtu);
let mut decoder = Decoder::new(conf); let mut decoder = Decoder::new(conf);

View file

@ -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) 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] #[no_mangle]
pub extern "C" fn wire_decode_packets( pub extern "C" fn wire_decode_packets(
port_: i64, port_: i64,

View file

@ -35,6 +35,19 @@ fn wire_get_tx_config_impl(port_: MessagePort, bytes: impl Wire2Api<Vec<u8>> + U
}, },
) )
} }
fn wire_drop_tx_config_impl(port_: MessagePort, _txc: impl Wire2Api<TxConfig> + 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( fn wire_decode_packets_impl(
port_: MessagePort, port_: MessagePort,
packets: impl Wire2Api<Vec<RaptorPacket>> + UnwindSafe, packets: impl Wire2Api<Vec<RaptorPacket>> + UnwindSafe,