add drop code for txconf
This commit is contained in:
parent
69ae823e68
commit
85c60913d5
6 changed files with 71 additions and 11 deletions
|
@ -13,6 +13,10 @@ abstract class Native {
|
|||
|
||||
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});
|
||||
|
||||
FlutterRustBridgeTaskConstMeta get kDecodePacketsConstMeta;
|
||||
|
|
|
@ -40,6 +40,22 @@ class NativeImpl implements Native {
|
|||
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}) {
|
||||
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 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(
|
||||
int port_,
|
||||
ffi.Pointer<wire_list_raptor_packet> 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<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 {
|
||||
@ffi.Uint64()
|
||||
external int len;
|
||||
|
@ -377,6 +401,17 @@ final class wire_TxConfig extends ffi.Struct {
|
|||
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
|
||||
= ffi.Pointer<ffi.NativeFunction<ffi.Bool Function(DartPort port_id, ffi.Pointer<ffi.Void> message)>>;
|
||||
typedef DartPort = ffi.Int64;
|
||||
|
|
|
@ -122,6 +122,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
{
|
||||
var txconf = await api.getTxConfig(bytes: dbytes);
|
||||
if (txconf != null || barcode.rawValue != null) {
|
||||
await api.dropTxConfig(txc: txconf!);
|
||||
continue;
|
||||
}
|
||||
final packet = RaptorPacket(field0: dbytes);
|
||||
|
|
|
@ -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>> {
|
||||
let conf = ObjectTransmissionInformation::with_defaults(txconf.len, txconf.mtu);
|
||||
let mut decoder = Decoder::new(conf);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
port_: MessagePort,
|
||||
packets: impl Wire2Api<Vec<RaptorPacket>> + UnwindSafe,
|
||||
|
|
Loading…
Reference in a new issue