Skip to content

Commit

Permalink
Unify binary types
Browse files Browse the repository at this point in the history
  • Loading branch information
temeddix committed Jun 16, 2024
1 parent 11b86f0 commit 3434b87
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions flutter_ffi_plugin/bin/src/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -418,20 +418,20 @@ use std::sync::OnceLock;
use tokio::sync::mpsc::unbounded_channel;
type SignalHandlers = OnceLock<
HashMap<i32, Box<dyn Fn(&[u8], Vec<u8>)
HashMap<i32, Box<dyn Fn(&[u8], &[u8])
-> Result<(), Box<dyn Error>> + Send + Sync>>,
>;
static SIGNAL_HANDLERS: SignalHandlers = OnceLock::new();
pub fn handle_dart_signal(
message_id: i32,
message_bytes: &[u8],
binary: Vec<u8>
binary: &[u8]
) {
let hash_map = SIGNAL_HANDLERS.get_or_init(|| {
let mut new_hash_map = HashMap::<
i32,
Box<dyn Fn(&[u8], Vec<u8>)
Box<dyn Fn(&[u8], &[u8])
-> Result<(), Box<dyn Error>> + Send + Sync>,
>::new();
''';
Expand All @@ -452,14 +452,14 @@ pub fn handle_dart_signal(
rustReceiveScript += '''
new_hash_map.insert(
${markedMessage.id},
Box::new(|message_bytes: &[u8], binary: Vec<u8>| {
Box::new(|message_bytes: &[u8], binary: &[u8]| {
use super::$modulePath$filename::*;
let message = ${normalizePascal(messageName)}::decode(
message_bytes
)?;
let dart_signal = DartSignal {
message,
binary,
binary: binary.to_vec(),
};
let mut guard = ${snakeName.toUpperCase()}_CHANNEL.lock()?;
if guard.is_none() {
Expand Down

0 comments on commit 3434b87

Please sign in to comment.