cancel_this/triggers/
mod.rs1use dyn_clone::{DynClone, clone_trait_object};
2
3mod timer;
4pub use timer::*;
5
6mod chain;
7pub use chain::*;
8
9mod never;
10pub use never::*;
11
12mod atomic;
13pub use atomic::*;
14
15#[cfg(feature = "memory")]
16mod memory;
17#[cfg(feature = "memory")]
18pub use memory::*;
19
20#[cfg(feature = "ctrlc")]
21mod ctrlc;
22#[cfg(feature = "ctrlc")]
23pub use ctrlc::*;
24
25#[cfg(feature = "pyo3")]
26mod pyo3;
27#[cfg(feature = "pyo3")]
28pub use pyo3::*;
29
30pub trait CancellationTrigger: Send + Sync + DynClone {
39 fn is_cancelled(&self) -> bool;
44
45 fn type_name(&self) -> &'static str;
48}
49
50clone_trait_object!(CancellationTrigger);
51
52pub type DynamicCancellationTrigger = Box<dyn CancellationTrigger>;
54
55impl CancellationTrigger for DynamicCancellationTrigger {
56 fn is_cancelled(&self) -> bool {
57 self.as_ref().is_cancelled()
58 }
59
60 fn type_name(&self) -> &'static str {
61 self.as_ref().type_name()
62 }
63}