LCOV - differential code coverage report
Current view: top level - libs/utils/src - signals.rs (source / functions) Coverage Total Hit UBC CBC
Current: f6946e90941b557c917ac98cd5a7e9506d180f3e.info Lines: 68.8 % 16 11 5 11
Current Date: 2023-10-19 02:04:12 Functions: 75.0 % 4 3 1 3
Baseline: c8637f37369098875162f194f92736355783b050.info
Baseline Date: 2023-10-18 20:25:20

           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         902 :     pub fn name(&self) -> &'static str {
      13             902 :         match self {
      14             411 :             Signal::Quit => "SIGQUIT",
      15 UBC           0 :             Signal::Interrupt => "SIGINT",
      16 CBC         491 :             Signal::Terminate => "SIGTERM",
      17                 :         }
      18             902 :     }
      19                 : }
      20                 : 
      21                 : pub struct ShutdownSignals;
      22                 : 
      23                 : impl ShutdownSignals {
      24             912 :     pub fn handle(mut handler: impl FnMut(Signal) -> anyhow::Result<()>) -> anyhow::Result<()> {
      25             912 :         for raw_signal in Signals::new(TERM_SIGNALS)?.into_iter() {
      26             902 :             let signal = match raw_signal {
      27 UBC           0 :                 SIGINT => Signal::Interrupt,
      28 CBC         491 :                 SIGTERM => Signal::Terminate,
      29             411 :                 SIGQUIT => Signal::Quit,
      30 UBC           0 :                 other => panic!("unknown signal: {}", other),
      31                 :             };
      32                 : 
      33 CBC         902 :             handler(signal)?;
      34                 :         }
      35                 : 
      36 UBC           0 :         Ok(())
      37               0 :     }
      38                 : }
        

Generated by: LCOV version 2.1-beta