refactor: idiomatic Rust cleanup and quality improvements
- Replace .map().unwrap_or(false) with .is_some_and()/.is_ok_and()
- Use path.display() instead of {:?} for user-facing messages
- Replace Option<Option<Vec<String>>> with GamescopeUpdate enum
- Replace manual parent-walking loops with .ancestors() iterators
- Simplify kill()/kill_all() signatures to return () instead of Result
- Use tokio::task::spawn_blocking instead of hand-rolled thread+oneshot
- Read /proc/self/status for UID instead of spawning id subprocess
- Build Exec= line directly in render_desktop instead of string-replace
- Bump PKGBUILD pkgrel to 6
This commit is contained in:
+4
-8
@@ -1,6 +1,4 @@
|
||||
use iced::futures::channel::oneshot;
|
||||
|
||||
/// Run a blocking closure on a thread pool thread and await its result.
|
||||
/// Run a blocking closure on the tokio blocking thread pool and await its result.
|
||||
/// Used to offload blocking work (HTTP, disk, process spawning) without
|
||||
/// stalling the iced event loop.
|
||||
pub async fn async_blocking<T, F>(f: F) -> T
|
||||
@@ -8,11 +6,9 @@ where
|
||||
T: Send + 'static,
|
||||
F: FnOnce() -> T + Send + 'static,
|
||||
{
|
||||
let (tx, rx) = oneshot::channel();
|
||||
std::thread::spawn(move || {
|
||||
let _ = tx.send(f());
|
||||
});
|
||||
rx.await.expect("blocking task panicked")
|
||||
tokio::task::spawn_blocking(f)
|
||||
.await
|
||||
.expect("blocking task panicked")
|
||||
}
|
||||
|
||||
/// Open a native folder picker dialog and return the chosen path, or None if
|
||||
|
||||
Reference in New Issue
Block a user