flare_core_runtime/signal/
ctrl_c.rs1use super::ShutdownSignal;
4use std::pin::Pin;
5
6pub struct CtrlCSignal {
18 name: String,
19}
20
21impl CtrlCSignal {
22 pub fn new() -> Self {
24 Self {
25 name: "ctrl_c".to_string(),
26 }
27 }
28}
29
30impl Default for CtrlCSignal {
31 fn default() -> Self {
32 Self::new()
33 }
34}
35
36impl ShutdownSignal for CtrlCSignal {
37 fn wait(&mut self) -> Pin<Box<dyn std::future::Future<Output = ()> + Send + '_>> {
38 Box::pin(async {
39 let _ = tokio::signal::ctrl_c().await;
40 })
41 }
42
43 fn name(&self) -> &str {
44 &self.name
45 }
46}
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_ctrl_c_signal_new() {
54 let signal = CtrlCSignal::new();
55 assert_eq!(signal.name(), "ctrl_c");
56 }
57}