-
This is my struct. When I added pub #[frb(dart_metadata=("freezed", "immutable" import "package:meta/meta.dart" as meta))]
#[derive(Clone)]
pub struct DevicePeripheralId {
pub name: String,
pub is_connected: bool,
pub address: String,
pub tx_power_level: Option<i16>,
pub rssi: Option<i16>,
pub manufacturer_data: HashMap<u16, Vec<u8>>,
pub service_data: HashMap<Uuid, Vec<u8>>,
pub services: Vec<Uuid>,
pub peripheral: BPeripheral, // There's a problem with this line of work
}
#[frb(dart_metadata=("freezed", "immutable" import "package:meta/meta.dart" as meta))]
#[derive(Clone)]
pub struct BPeripheral {
peripheral: Peripheral,
}
///This is a struct from another package,I cannot modify it
#[derive(Clone)]
pub struct Peripheral {
shared: Arc<Shared>,
}
#[frb(dart_metadata=("freezed", "immutable" import "package:meta/meta.dart" as meta))]
#[derive(Clone)]
pub enum BlueEvent {
DeviceDiscovered(DevicePeripheralId),
DeviceUpdated(DevicePeripheralId),
DeviceConnected(DevicePeripheralId),
DeviceDisconnected(DevicePeripheralId),
ManufacturerDataAdvertisement(DevicePeripheralId, HashMap<u16, Vec<u8>>),
ServiceDataAdvertisement(DevicePeripheralId, HashMap<Uuid, Vec<u8>>),
ServicesAdvertisement(DevicePeripheralId, Vec<Uuid>),
ERROR(String),
}
unsafe impl Send for DevicePeripheralId {}
unsafe impl Send for BlueEvent {}
unsafe impl Send for BPeripheral {} This is the generated code, without any attributes inside // Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BlueEvent>>
abstract class BlueEvent implements RustOpaqueInterface {} After I deleted this @freezed
sealed class BlueEvent with _$BlueEvent {
const BlueEvent._();
const factory BlueEvent.deviceDiscovered(
DevicePeripheralId field0,
) = BlueEvent_DeviceDiscovered;
const factory BlueEvent.deviceUpdated(
DevicePeripheralId field0,
) = BlueEvent_DeviceUpdated;
const factory BlueEvent.deviceConnected(
DevicePeripheralId field0,
) = BlueEvent_DeviceConnected;
const factory BlueEvent.deviceDisconnected(
DevicePeripheralId field0,
) = BlueEvent_DeviceDisconnected;
const factory BlueEvent.manufacturerDataAdvertisement(
DevicePeripheralId field0,
Map<int, Uint8List> field1,
) = BlueEvent_ManufacturerDataAdvertisement;
const factory BlueEvent.serviceDataAdvertisement(
DevicePeripheralId field0,
Map<UuidValue, Uint8List> field1,
) = BlueEvent_ServiceDataAdvertisement;
const factory BlueEvent.servicesAdvertisement(
DevicePeripheralId field0,
List<UuidValue> field1,
) = BlueEvent_ServicesAdvertisement;
const factory BlueEvent.error(
String field0,
) = BlueEvent_ERROR;
}
|
Beta Was this translation helpful? Give feedback.
Answered by
fzyzcjy
Nov 9, 2024
Replies: 1 comment 2 replies
-
Looks like because BPeripheral is opaque, then makes DevicePeripheralId opaque. What about trying
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
mdddj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like because BPeripheral is opaque, then makes DevicePeripheralId opaque.
What about trying