#![warn(clippy::all, clippy::pedantic)] use log::info; pub mod command; pub mod logger; pub mod on_drop; pub mod telemetry; pub mod udp; /// Add a ctrl-c handler which will set an atomic flag to `false` when ctrl-c is detected /// /// # Errors /// If a system error occurred while trying to set the ctrl-c handler pub fn add_ctrlc_handler_arc( flag: std::sync::Arc, ) -> anyhow::Result<()> { ctrlc::set_handler(move || { info!("Shutdown Requested"); flag.store(false, std::sync::atomic::Ordering::Relaxed); })?; Ok(()) } /// Add a ctrl-c handler which will set an atomic flag to `false` when ctrl-c is detected /// /// # Errors /// If a system error occurred while trying to set the ctrl-c handler #[cfg(feature = "async")] pub fn add_ctrlc_handler_cancel(cancel: tokio_util::sync::CancellationToken) -> anyhow::Result<()> { ctrlc::set_handler(move || { info!("Shutdown Requested"); cancel.cancel(); })?; Ok(()) }