LCOV - differential code coverage report
Current view: top level - libs/utils/src - signals.rs (source / functions) Coverage Total Hit UBC CBC
Current: cd44433dd675caa99df17a61b18949c8387e2242.info Lines: 68.8 % 16 11 5 11
Current Date: 2024-01-09 02:06:09 Functions: 80.0 % 5 4 1 4
Baseline: 66c52a629a0f4a503e193045e0df4c77139e344b.info
Baseline Date: 2024-01-08 15:34:46

           TLA  Line data    Source code
       1                 : use signal_hook::iterator::Signals;
       2                 : 
       3                 : pub use signal_hook::consts::{signal::*, TERM_SIGNALS};
       4                 : 
       5                 : pub enum Signal {
       6                 :     Quit,
       7                 :     Interrupt,
       8                 :     Terminate,
       9                 : }
      10                 : 
      11                 : impl Signal {
      12 CBC        1218 :     pub fn name(&self) -> &'static str {
      13            1218 :         match self {
      14             720 :             Signal::Quit => "SIGQUIT",
      15 UBC           0 :             Signal::Interrupt => "SIGINT",
      16 CBC         498 :             Signal::Terminate => "SIGTERM",
      17                 :         }
      18            1218 :     }
      19                 : }
      20                 : 
      21                 : pub struct ShutdownSignals;
      22                 : 
      23                 : impl ShutdownSignals {
      24            1229 :     pub fn handle(mut handler: impl FnMut(Signal) -> anyhow::Result<()>) -> anyhow::Result<()> {
      25            1229 :         for raw_signal in Signals::new(TERM_SIGNALS)?.into_iter() {
      26            1218 :             let signal = match raw_signal {
      27 UBC           0 :                 SIGINT => Signal::Interrupt,
      28 CBC         498 :                 SIGTERM => Signal::Terminate,
      29             720 :                 SIGQUIT => Signal::Quit,
      30 UBC           0 :                 other => panic!("unknown signal: {}", other),
      31                 :             };
      32                 : 
      33 CBC        1218 :             handler(signal)?;
      34                 :         }
      35                 : 
      36 UBC           0 :         Ok(())
      37               0 :     }
      38                 : }
        

Generated by: LCOV version 2.1-beta