From 6c19ef9251f4cd751bd22cb5e5e9086ebb29485f Mon Sep 17 00:00:00 2001 From: Thomas Karpiniec Date: Tue, 12 May 2026 01:50:18 +0000 Subject: [PATCH] Add compile check that changed() is Send on Android --- android/app-native/src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/android/app-native/src/lib.rs b/android/app-native/src/lib.rs index e2f1965..7904fc5 100644 --- a/android/app-native/src/lib.rs +++ b/android/app-native/src/lib.rs @@ -40,6 +40,23 @@ impl Drop for AsyncWatcher { } } +/// Compile-time check that `AsyncWatch::changed()` returns a `Send` future on Android. +pub fn compile_check_changed_future_is_send_for_tokio_spawned_task() { + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .expect("failed to build tokio runtime"); + runtime.block_on(async { + let mut watch = netwatcher::watch_interfaces_async::() + .expect("failed to create async watcher"); + + let task = tokio::spawn(async move { watch.changed().await }); + let initial = task.await.expect("spawned watch task failed"); + + assert!(initial.is_initial); + }); +} + fn init_android_logging() { android_logger::init_once( android_logger::Config::default().with_max_level(log::LevelFilter::Debug),