tauri_store_utils/
task.rs1use crate::sync::MutexOption;
2use std::ops::Deref;
3use tokio::task::AbortHandle;
4
5pub trait RemoteCallable<T> {
8 fn call(&self, ctx: &T);
10 fn abort(&self);
12}
13
14#[derive(Default)]
15pub(crate) struct OptionalAbortHandle(MutexOption<AbortHandle>);
16
17impl OptionalAbortHandle {
18 pub(crate) fn abort(&self) {
19 if let Some(handle) = self.0.take() {
20 handle.abort();
21 }
22 }
23}
24
25impl Deref for OptionalAbortHandle {
26 type Target = MutexOption<AbortHandle>;
27
28 fn deref(&self) -> &Self::Target {
29 &self.0
30 }
31}